pub struct ParsedPacket { /* private fields */ }Expand description
Structured packet view backed by the preserved raw packet bytes.
Implementations§
Source§impl ParsedPacket
impl ParsedPacket
Sourcepub fn source(&self) -> &[u8] ⓘ
pub fn source(&self) -> &[u8] ⓘ
Returns the source callsign bytes before the > separator.
Examples found in repository?
examples/parse_packet.rs (line 6)
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}Sourcepub fn destination(&self) -> &[u8] ⓘ
pub fn destination(&self) -> &[u8] ⓘ
Returns the destination bytes, which are the first path component.
Examples found in repository?
examples/parse_packet.rs (line 9)
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}Sourcepub fn digipeaters(&self) -> Vec<&[u8]>
pub fn digipeaters(&self) -> Vec<&[u8]>
Returns digipeater path component byte views after the destination.
Sourcepub fn path_components(&self) -> Vec<&[u8]>
pub fn path_components(&self) -> Vec<&[u8]>
Returns all path component byte views, including destination first.
Sourcepub fn data_type_identifier(&self) -> DataTypeIdentifier
pub fn data_type_identifier(&self) -> DataTypeIdentifier
Returns the APRS data type identifier from the first payload byte.
Sourcepub fn information(&self) -> &[u8] ⓘ
pub fn information(&self) -> &[u8] ⓘ
Returns payload bytes after the data type identifier.
Sourcepub fn aprs_data(&self) -> AprsData<'_>
pub fn aprs_data(&self) -> AprsData<'_>
Returns a semantic view of the APRS information field.
Examples found in repository?
examples/parse_packet.rs (line 12)
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}Sourcepub fn to_json(&self) -> String
pub fn to_json(&self) -> String
Serializes the parsed packet into a compact JSON diagnostic string.
Examples found in repository?
examples/process_file.rs (line 14)
3fn main() -> std::io::Result<()> {
4 let Some(path) = std::env::args().nth(1) else {
5 eprintln!("usage: process_file <packets.aprs>");
6 std::process::exit(2);
7 };
8
9 let input = std::fs::read(path)?;
10 let mut engine = Engine::new(Policy::strict());
11
12 for packet_bytes in LineTransport::new(&input).packets() {
13 match engine.process(packet_bytes) {
14 EngineResult::Accepted { packet } => println!("{}", packet.to_json()),
15 EngineResult::Rejected { reason, .. } => eprintln!("rejected: {}", reason.code()),
16 EngineResult::ParseError(error) => eprintln!("malformed: {}", error.code()),
17 }
18 }
19
20 Ok(())
21}Trait Implementations§
Source§impl Clone for ParsedPacket
impl Clone for ParsedPacket
Source§fn clone(&self) -> ParsedPacket
fn clone(&self) -> ParsedPacket
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ParsedPacket
impl Debug for ParsedPacket
Source§impl PartialEq for ParsedPacket
impl PartialEq for ParsedPacket
impl Eq for ParsedPacket
impl StructuralPartialEq for ParsedPacket
Auto Trait Implementations§
impl Freeze for ParsedPacket
impl RefUnwindSafe for ParsedPacket
impl Send for ParsedPacket
impl Sync for ParsedPacket
impl Unpin for ParsedPacket
impl UnsafeUnpin for ParsedPacket
impl UnwindSafe for ParsedPacket
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more