Skip to main content

Module args

Module args 

Source
Expand description

Argument splitting for one AT response / URC line (V.250 §5.4.2, 3GPP TS 27.007 §4).

split cuts a parameter list on top-level commas. Commas inside a quoted string or inside parentheses ((0-5), (2,"Op","Op","00101",7)) do not split. Each Arg keeps whether it was quoted, so "0001" (a string) and 0001 (a number) stay distinguishable.

use serial_codec::args::{split, strip_prefix};

let body = strip_prefix("+CMGL: 1,\"REC READ\",\"a,b\",,", "+CMGL").unwrap();
let a = split(body);
assert_eq!(a.len(), 5);
assert_eq!(a[0].int::<u32>(), Some(1));
assert_eq!(a[2].str(), Some("a,b"));
assert!(a[3].is_empty() && a[4].is_empty());

Structs§

Arg
One comma-separated parameter.

Functions§

parse_ranges
Parses a 27.007 range list such as 0-1,3 or (0-5) into inclusive ranges. None on anything that is not digits, - and ,.
parse_values
parse_ranges expanded to the listed values; ranges wider than 1024 values are refused (None) so a hostile (0-4294967295) cannot allocate gigabytes.
split
Splits a parameter list on top-level commas.
strip_prefix
Returns the text after <prefix>: when line starts with prefix (ASCII case-insensitive). Surrounding whitespace / CR LF and spaces before or after the colon are allowed. strip_prefix("+CREG: 1", "+CREG") is Some("1"); "+CREGX: 1" does not match.