Skip to main content

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 =
15    time::Duration::from_micros(50);
16
17/// Trait describing a packet reader
18pub trait Reader: Send {
19    /// Should return the next packet off of the wire
20    fn next_packet(&mut self) -> Result<&[u8]>;
21}
22
23/// Trait describing a packet sender
24pub trait Sender: Send {
25    /// Should send a packet over the wire
26    fn send(&mut self, packet: &[u8]) -> Result<()>;
27}
28
29#[cfg(test)]
30#[path = "./packet_tests.rs"]
31#[doc(hidden)]
32pub mod mocks;