pub struct SimulatedNetwork { /* private fields */ }Expand description
A simulated network that models latency, jitter, loss, duplication, and reordering.
Implementations§
Source§impl SimulatedNetwork
impl SimulatedNetwork
Sourcepub fn new(config: NetworkConfig) -> Self
pub fn new(config: NetworkConfig) -> Self
Creates a new SimulatedNetwork with the given configuration.
Sourcepub fn config(&self) -> &NetworkConfig
pub fn config(&self) -> &NetworkConfig
Returns a reference to the active network configuration.
Sourcepub fn config_mut(&mut self) -> &mut NetworkConfig
pub fn config_mut(&mut self) -> &mut NetworkConfig
Mutably updates the network configuration during simulation.
Sourcepub fn send(
&mut self,
payload: Vec<u8>,
src: SocketAddr,
dst: SocketAddr,
now: Instant,
)
pub fn send( &mut self, payload: Vec<u8>, src: SocketAddr, dst: SocketAddr, now: Instant, )
Sends a payload through the simulated network.
Sourcepub fn receive(&mut self, now: Instant) -> Option<QueuedDatagram>
pub fn receive(&mut self, now: Instant) -> Option<QueuedDatagram>
Receives a datagram from the network if it’s ready.
Auto Trait Implementations§
impl Freeze for SimulatedNetwork
impl RefUnwindSafe for SimulatedNetwork
impl Send for SimulatedNetwork
impl Sync for SimulatedNetwork
impl Unpin for SimulatedNetwork
impl UnsafeUnpin for SimulatedNetwork
impl UnwindSafe for SimulatedNetwork
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