Struct smoltcp::phy::FaultInjector[][src]

pub struct FaultInjector<D: for<'a> Device<'a>> { /* fields omitted */ }

A fault injector device.

A fault injector is a device that alters packets traversing through it to simulate adverse network conditions (such as random packet loss or corruption), or software or hardware limitations (such as a limited number or size of usable network buffers).

Implementations

impl<D: for<'a> Device<'a>> FaultInjector<D>[src]

pub fn new(inner: D, seed: u32) -> FaultInjector<D>[src]

Create a fault injector device, using the given random number generator seed.

pub fn into_inner(self) -> D[src]

Return the underlying device, consuming the fault injector.

pub fn corrupt_chance(&self) -> u8[src]

Return the probability of corrupting a packet, in percents.

pub fn drop_chance(&self) -> u8[src]

Return the probability of dropping a packet, in percents.

pub fn max_packet_size(&self) -> usize[src]

Return the maximum packet size, in octets.

pub fn max_tx_rate(&self) -> u64[src]

Return the maximum packet transmission rate, in packets per second.

pub fn max_rx_rate(&self) -> u64[src]

Return the maximum packet reception rate, in packets per second.

pub fn bucket_interval(&self) -> Duration[src]

Return the interval for packet rate limiting, in milliseconds.

pub fn set_corrupt_chance(&mut self, pct: u8)[src]

Set the probability of corrupting a packet, in percents.

Panics

This function panics if the probability is not between 0% and 100%.

pub fn set_drop_chance(&mut self, pct: u8)[src]

Set the probability of dropping a packet, in percents.

Panics

This function panics if the probability is not between 0% and 100%.

pub fn set_max_packet_size(&mut self, size: usize)[src]

Set the maximum packet size, in octets.

pub fn set_max_tx_rate(&mut self, rate: u64)[src]

Set the maximum packet transmission rate, in packets per interval.

pub fn set_max_rx_rate(&mut self, rate: u64)[src]

Set the maximum packet reception rate, in packets per interval.

pub fn set_bucket_interval(&mut self, interval: Duration)[src]

Set the interval for packet rate limiting, in milliseconds.

Trait Implementations

impl<D: Debug + for<'a> Device<'a>> Debug for FaultInjector<D>[src]

impl<'a, D> Device<'a> for FaultInjector<D> where
    D: for<'b> Device<'b>, 
[src]

type RxToken = RxToken<'a, <D as Device<'a>>::RxToken>

type TxToken = TxToken<'a, <D as Device<'a>>::TxToken>

Auto Trait Implementations

impl<D> !RefUnwindSafe for FaultInjector<D>

impl<D> Send for FaultInjector<D> where
    D: Send

impl<D> !Sync for FaultInjector<D>

impl<D> Unpin for FaultInjector<D> where
    D: Unpin

impl<D> UnwindSafe for FaultInjector<D> where
    D: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.