#[cfg(feature = "packetmeta-timestamp")]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Default)]
pub struct Timestamp {
pub seconds: u32,
pub quarter_nanos: u32,
}
#[cfg(feature = "packetmeta-timestamp")]
impl Timestamp {
pub const fn from_seconds_and_nanos(seconds: u32, nanos: u32) -> Self {
Self {
seconds,
quarter_nanos: nanos << 2,
}
}
pub const fn nanos(&self) -> u32 {
self.quarter_nanos >> 2
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Default)]
#[non_exhaustive]
pub struct PacketMeta {
#[cfg(feature = "packetmeta-id")]
pub id: u32,
#[cfg(feature = "packetmeta-timestamp")]
pub timestamp: Option<Timestamp>,
#[cfg(feature = "packetmeta-timestamp")]
pub request_timestamp: bool,
}
#[cfg(feature = "packetmeta-timestamp")]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub struct TxTimestamp {
pub id: u32,
pub timestamp: Timestamp,
}