[−][src]Function dia_args::parse_stream
pub fn parse_stream(
stream: &mut dyn Read,
max_size: Option<u64>
) -> Result<Args>
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_size
is zero, an error is returned. IfNone
,MAX_DIA_ARGS_FILE_SIZE
will 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));