pub struct Relay { /* private fields */ }Expand description
A Relay forwards PacketRcs between PacketDevices, optionally enforcing a
bandwidth limit on the rate at which we forward PacketRcs between devices.
The Relay is considered the “active” part of the PacketRc forwarding
process: it initiates PacketRc forwarding and internally schedules tasks to
ensure that PacketRcs are continually forwarded over time without exceeding
the configured RateLimit.
An Ipv4Addr associated with a source PacketDevice object is supplied
when creating a Relay. This Ipv4Addr is only meaningful to the extent
that the Host understands how to map this Ipv4Addr to the intended
PacketDevice when Host::get_packet_device(Ipv4Addr) is called. This
source PacketDevice supplies the Relay with a stream of PacketRcs
(through its implementation of PacketDevice::pop()) that the Relay will
forward to a destination.
Relay::notify() must be called whenever the source PacketDevice changes
state from empty to non-empty, to trigger an idle Relay to start
forwarding PacketRcs again.
For each PacketRc that needs to be forwarded, the Relay uses the
PacketRc’s destination Ipv4Addr to obtain the destination PacketDevice
from the Host by calling its Host::get_packet_device(Ipv4Addr) function.
The PacketRc is forwarded to the destination through the destination
PacketDevice’s implementation of PacketDevice::push().
This design allows the Host to use Host::get_packet_device to define its
own routing table.
Note that PacketRcs forwarded between identical source and destination
PacketDevices are considered “local” to that device and exempt from any
configured RateLimit.
Implementations§
Source§impl Relay
 
impl Relay
Sourcepub fn new(rate: RateLimit, src_dev_address: Ipv4Addr) -> Self
 
pub fn new(rate: RateLimit, src_dev_address: Ipv4Addr) -> Self
Creates a new Relay that will forward PacketRcs following the given
RateLimit from the PacketDevice returned by the Host when passing
the given src_dev_address to Host::get_packet_device(). The Relay
internally schedules tasks as needed to ensure packets continue to be
forwarded over time without exceeding the configured RateLimit.
Auto Trait Implementations§
impl !Freeze for Relay
impl !RefUnwindSafe for Relay
impl Send for Relay
impl Sync for Relay
impl Unpin for Relay
impl !UnwindSafe for Relay
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
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>
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>
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