1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use crate::{stack_str::PackArrayString, AprsHeader};
use self::{position::AprsPosition, wx::AprsWx};
pub mod header;
pub mod position;
pub mod wx;
pub struct AprsPacket<'a> {
pub header: AprsHeader<'a>,
pub position: Option<AprsPosition>,
pub wx: Option<AprsWx>,
pub message: Option<&'a str>,
}
impl AprsPacket<'_> {}
impl PackArrayString for AprsPacket<'_> {
fn pack_into<const SIZE: usize>(
&self,
s: &mut arrayvec::ArrayString<SIZE>,
) -> Result<(), crate::errors::PackError> {
self.header.pack_into(s)?;
s.try_push(':')?;
if self.position.is_some() {
self.position.as_ref().unwrap().pack_into(s)?;
}
if self.wx.is_some() {
self.wx.as_ref().unwrap().pack_into(s)?;
}
if self.message.is_some() {
s.try_push_str(self.message.as_ref().unwrap())?;
}
Ok(())
}
}