Skip to main content

encode

Function encode 

Source
pub fn encode<A: AsRef<[u8]>>(verb: &str, args: &[A]) -> String
Expand description

Encodes one directive line, without the trailing newline.

Arguments are raw bytes (&str, String, &[u8], …) and are written as standard padded base64. An empty argument becomes an empty word, so encode("export", &["X", ""]) ends in a space.

use shellgame::shell::protocol::encode;

assert_eq!(encode("echo", &["hello"]), "__SHELLGAME_EXEC__v1 echo aGVsbG8=");
assert_eq!(encode::<&str>("exit", &[]), "__SHELLGAME_EXEC__v1 exit");