pub struct DataPacket {
pub packet_id: String,
pub source_node_id: String,
pub destination_node_id: Option<String>,
pub data_type: DataType,
pub direction: DataDirection,
pub hop_count: u16,
pub max_hops: u16,
pub payload: Vec<u8>,
}Expand description
Data packet metadata for routing decisions
Fields§
§packet_id: StringUnique packet identifier
source_node_id: StringNode ID of the original sender
destination_node_id: Option<String>Node ID of the intended final recipient (None = broadcast)
data_type: DataTypeType of data in this packet
direction: DataDirectionDirection of data flow
hop_count: u16Hop count (incremented at each forward)
max_hops: u16Maximum hops before packet is dropped (prevents loops)
payload: Vec<u8>Payload data (opaque to router)
Implementations§
Source§impl DataPacket
impl DataPacket
Sourcepub fn telemetry(source_node_id: impl Into<String>, payload: Vec<u8>) -> Self
pub fn telemetry(source_node_id: impl Into<String>, payload: Vec<u8>) -> Self
Create a new telemetry packet
Sourcepub fn command(
source_node_id: impl Into<String>,
destination_node_id: impl Into<String>,
payload: Vec<u8>,
) -> Self
pub fn command( source_node_id: impl Into<String>, destination_node_id: impl Into<String>, payload: Vec<u8>, ) -> Self
Create a new command packet
Sourcepub fn status(source_node_id: impl Into<String>, payload: Vec<u8>) -> Self
pub fn status(source_node_id: impl Into<String>, payload: Vec<u8>) -> Self
Create a new status update packet
Sourcepub fn coordination(
source_node_id: impl Into<String>,
destination_node_id: impl Into<String>,
payload: Vec<u8>,
) -> Self
pub fn coordination( source_node_id: impl Into<String>, destination_node_id: impl Into<String>, payload: Vec<u8>, ) -> Self
Create a new coordination packet (lateral)
Sourcepub fn aggregated_telemetry(
source_node_id: impl Into<String>,
payload: Vec<u8>,
) -> Self
pub fn aggregated_telemetry( source_node_id: impl Into<String>, payload: Vec<u8>, ) -> Self
Create an aggregated telemetry packet
Sourcepub fn increment_hop(&mut self) -> bool
pub fn increment_hop(&mut self) -> bool
Increment hop count when forwarding packet
Returns true if packet can be forwarded (not yet at max hops), false if packet should be dropped.
Sourcepub fn at_max_hops(&self) -> bool
pub fn at_max_hops(&self) -> bool
Check if packet has reached maximum hop count
Trait Implementations§
Source§impl Clone for DataPacket
impl Clone for DataPacket
Source§fn clone(&self) -> DataPacket
fn clone(&self) -> DataPacket
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 DataPacket
impl Debug for DataPacket
Source§impl<'de> Deserialize<'de> for DataPacket
impl<'de> Deserialize<'de> for DataPacket
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for DataPacket
impl RefUnwindSafe for DataPacket
impl Send for DataPacket
impl Sync for DataPacket
impl Unpin for DataPacket
impl UnsafeUnpin for DataPacket
impl UnwindSafe for DataPacket
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