r_lanlib/
packet.rs

1//! Provides helpers for creating and sending packets
2
3use core::time;
4
5pub mod arp_packet;
6pub mod heartbeat_packet;
7pub mod rst_packet;
8pub mod syn_packet;
9pub mod wire;
10
11use crate::error::Result;
12
13/// Default timing for throttling packet sends to prevent packet loss
14pub const DEFAULT_PACKET_SEND_TIMING: time::Duration = time::Duration::from_micros(50);
15
16/// Trait describing a packet reader
17pub trait Reader: Send + Sync {
18    /// Should return the next packet off of the wire
19    fn next_packet(&mut self) -> Result<&[u8]>;
20}
21
22/// Trait describing a packet sender
23pub trait Sender: Send + Sync {
24    /// Should send a packet over the wire
25    fn send(&mut self, packet: &[u8]) -> Result<()>;
26}
27
28#[cfg(test)]
29#[path = "./packet_tests.rs"]
30#[doc(hidden)]
31pub mod mocks;