Struct pnet_datalink::dummy::Config

source ·
pub struct Config { /* private fields */ }
Expand description

Configuration for the dummy datalink backend. Contains std::sync::mpsc channels that are used to communicate with the fake network.

Implementations§

source§

impl Config

source

pub fn new( receiver: Receiver<Result<Box<[u8]>>>, sender: Sender<Box<[u8]>> ) -> Config

Creates a new Config with the given channels as the backing network. When using this constructor inject_handle and read_handle will return None. Those handles must be kept track of elsewhere.

The DataLinkReceiver created by the dummy backend will read packets from receiver. Both network errors and data can be sent on this channel. When the receiver channel is closed (Sender is dropped) DataLinkReceiver::next() will sleep forever, simlating an idle network.

The DataLinkSender created by the dummy backend will send all packets sent through build_and_send() and send_to() to the sender channel.

source

pub fn inject_handle(&mut self) -> Option<Sender<Result<Box<[u8]>>>>

Get the Sender handle that can inject packets in the fake network. Only usable with Configs generated from default().

source

pub fn read_handle(&mut self) -> Option<Receiver<Box<[u8]>>>

Get the Receiver handle where packets sent to the fake network can be read. Only usable with Configs generated from default().

Trait Implementations§

source§

impl Debug for Config

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Config

source§

fn default() -> Config

Creates a default config with one input and one output channel. The handles used to inject to and read form the network can be fetched with inject_handle() and read_handle().

source§

impl<'a> From<&'a Config> for Config

source§

fn from(_config: &Config) -> Config

Will not use the super::Config. This will simply call dummy::Config::default().

Auto Trait Implementations§

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl !Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.