Function dia_args::parse_stream [−][src]
pub fn parse_stream<R>(stream: &mut R, max_size: Option<u64>) -> Result<Args> where
R: Read,
Parses a stream of strings, separated by null byte (0)
This function can be useful for securely passing/parsing arguments across processes.
Notes
- If
max_sizeis zero, an error is returned. IfNone,MAX_DIA_ARGS_FILE_SIZEwill be used. If the stream has more data than provided value, an error is returned. - If the stream contains an invalid UTF-8 string, an error is returned.
- The stream is used as-is. So you might want to use
BufReader.
Examples
let stream = b"run\0--faster=true"; let args = dia_args::parse_stream(&mut &stream[..], None)?; assert_eq!(args.cmd(), Some("run")); assert_eq!(args.get(&["--faster"])?, Some(true));