Struct smoltcp::phy::FaultInjector
[−]
[src]
pub struct FaultInjector<T: Device> { /* fields omitted */ }
A fault injector device.
A fault injector is a device that randomly drops or corrupts packets traversing it, according to preset probabilities.
Methods
impl<T: Device> FaultInjector<T>
[src]
fn new(lower: T, seed: u32) -> FaultInjector<T>
Create a tracer device, using the given random number generator seed.
fn into_lower(self) -> T
Return the underlying device, consuming the tracer.
fn corrupt_chance(&self) -> u8
Return the probability of corrupting a packet, in percents.
fn drop_chance(&self) -> u8
Return the probability of dropping a packet, in percents.
fn set_corrupt_chance(&mut self, pct: u8)
Set the probability of corrupting a packet, in percents.
Panics
This function panics if the probability is not between 0% and 100%.
fn set_drop_chance(&mut self, pct: u8)
Set the probability of dropping a packet, in percents.
Panics
This function panics if the probability is not between 0% and 100%.
Trait Implementations
impl<T: Debug + Device> Debug for FaultInjector<T>
[src]
impl<T: Device> Device for FaultInjector<T> where
T::RxBuffer: AsMut<[u8]>,
[src]
T::RxBuffer: AsMut<[u8]>,
type RxBuffer = T::RxBuffer
type TxBuffer = TxBuffer<T::TxBuffer>
fn mtu(&self) -> usize
Get maximum transmission unit. Read more
fn receive(&mut self) -> Result<Self::RxBuffer, Error>
Receive a frame. Read more
fn transmit(&mut self, length: usize) -> Result<Self::TxBuffer, Error>
Transmit a frame. Read more