use serde::Serialize;
use crate::ParsedPacket;
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct PacketDiagnostic {
pub raw: Vec<u8>,
pub source: Vec<u8>,
pub destination: Vec<u8>,
pub path: Vec<u8>,
pub payload: Vec<u8>,
pub data_type: &'static str,
pub semantic: &'static str,
}
impl PacketDiagnostic {
#[must_use]
pub fn from_packet(packet: &ParsedPacket) -> Self {
Self {
raw: packet.raw().as_bytes().to_vec(),
source: packet.source().to_vec(),
destination: packet.destination().to_vec(),
path: packet.path().to_vec(),
payload: packet.payload().to_vec(),
data_type: packet.data_type_identifier().name(),
semantic: packet.aprs_data().kind_name(),
}
}
}