Skip to main content

parse_packet

Function parse_packet 

Source
pub fn parse_packet(input: &[u8]) -> Result<ParsedPacket, ParseError>
Expand description

Parses an APRS packet from untrusted bytes.

This parser intentionally validates only the minimal frame shape for the skeleton: source>path:payload. Payload bytes are opaque and may be invalid UTF-8.

Examples found in repository?
examples/parse_packet.rs (line 4)
3fn main() -> Result<(), libaprs_engine::ParseError> {
4    let packet = parse_packet(b"N0CALL>APRS:>hello")?;
5
6    println!("source={}", String::from_utf8_lossy(packet.source()));
7    println!(
8        "destination={}",
9        String::from_utf8_lossy(packet.destination())
10    );
11
12    if let AprsData::Status { text } = packet.aprs_data() {
13        println!("status={}", String::from_utf8_lossy(text));
14    }
15
16    Ok(())
17}