pub struct Context<'a, T> {
pub now: EmulatedTime,
pub is_bootstrapping: bool,
pub send_packet_fn: fn(&'a T, PacketRc),
pub get_packet_device_fn: fn(&'a T, Ipv4Addr) -> Option<Ref<'_, dyn PacketDevice>>,
pub fn_arg: &'a T,
}Expand description
Generalizes the runtime state needed to run the router.
Fields§
§now: EmulatedTimeThe current value of the runtime clock.
is_bootstrapping: boolIf the runtime is in bootstrapping mode, where rate limits are ignored.
send_packet_fn: fn(&'a T, PacketRc)The function the router will call when it needs to send a packet over the simulated network.
get_packet_device_fn: fn(&'a T, Ipv4Addr) -> Option<Ref<'_, dyn PacketDevice>>The function the router will call to obtain the underlying packet device
for the address configured in Router::attach_packet_device. The
underlying device is a src/stream for outgoing packets and a dst/sink
for incoming packets.
fn_arg: &'a TThe first argument that will be supplied when calling the
Context::send_packet_fn and Context::get_packet_device_fn
callback functions.
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> Freeze for Context<'a, T>
impl<'a, T> RefUnwindSafe for Context<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for Context<'a, T>where
T: Sync,
impl<'a, T> Sync for Context<'a, T>where
T: Sync,
impl<'a, T> Unpin for Context<'a, T>
impl<'a, T> UnsafeUnpin for Context<'a, T>
impl<'a, T> UnwindSafe for Context<'a, T>where
T: RefUnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Host for T
impl<T> Host for T
impl<T> Host for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more