Skip to main content

EnterGuard

Struct EnterGuard 

Source
pub struct EnterGuard { /* private fields */ }

Implementations§

Source§

impl EnterGuard

Source

pub fn egress_all(&self, out: &mut Vec<Packet>)

Drain every host’s outbound queue into out. The caller decides what happens next — typically: consult rules via EnterGuard::evaluate for each packet and then EnterGuard::deliver (or schedule for later). The buffer is passed in so the caller can reuse its allocation across ticks. See fixture for the default tokio-driven loop.

Source

pub fn deliver(&self, pkt: Packet)

Route a packet to the host owning its destination IP. Drops silently if no host is registered for that IP.

Source

pub fn evaluate(&self, pkt: &Packet) -> Verdict

Walk installed rules for pkt. First non-Pass verdict wins; empty rule chain returns Verdict::Pass.

Source

pub fn set_current(&self, id: HostId)

Pin which host subsequent sys() calls (i.e. socket syscalls from any task spawned inside this guard) talk to.

Source

pub fn rule(&self, r: impl Rule) -> RuleGuard

Install a rule, vending a RuleGuard that uninstalls it on drop. Useful in schedulers or fixture code that owns the guard’s lifetime explicitly — async tasks should call the free rule function instead.

Trait Implementations§

Source§

impl Drop for EnterGuard

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.