Struct netsim_embed_machine::Machine
source · pub struct Machine<C, E> { /* private fields */ }
Expand description
Spawns a thread in a new network namespace and configures a TUN interface that sends and receives IP packets from the tx/rx channels and runs some UDP/TCP networking code in task.
Implementations§
source§impl<C, E> Machine<C, E>
impl<C, E> Machine<C, E>
pub fn id(&self) -> MachineId
pub fn addr(&self) -> Ipv4Addr
pub fn mask(&self) -> u8
pub async fn set_addr(&mut self, addr: Ipv4Addr, mask: u8)
pub fn send(&self, cmd: C)
pub fn drain(&mut self) -> Vec<E>
pub fn up(&self)
pub fn down(&self)
pub fn namespace(&self) -> Namespace
pub async fn recv(&mut self) -> Option<E>
pub async fn select<F, T>(&mut self, f: F) -> Option<T>
pub async fn select_draining<F, T>(&mut self, f: F) -> Option<T>
pub fn drain_matching<F: FnMut(&E) -> bool>(&mut self, f: F) -> Vec<E>
Trait Implementations§
Auto Trait Implementations§
impl<C, E> !RefUnwindSafe for Machine<C, E>
impl<C, E> Send for Machine<C, E>
impl<C, E> Sync for Machine<C, E>
impl<C, E> Unpin for Machine<C, E>where
E: Unpin,
impl<C, E> !UnwindSafe for Machine<C, E>
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