For AT commands that include a length-prefixed payload (common in some modem protocols), use the LengthDelimited type (available when the heapless feature is enabled).
This type can parse payloads that are:
- Quoted:
"<length>,<payload>" - Unquoted:
<length>,<payload> - Separated by a line break:
<length>\r\n<payload>
use serde::Deserialize;
// Note: requires 'heapless' feature
use atat::length_delimited::LengthDelimited;
#[derive(Deserialize, Debug, PartialEq)]
struct PayloadResponse {
pub ctx: u8,
pub id: i8,
pub payload: LengthDelimited<32>,
}
// Example: parsing "1,-1,9,\"ABCD,1234\""
// Result: ctx=1, id=-1, payload=b"ABCD,1234"