pub trait TxToken {
fn consume<R, F>(self, timestamp: Instant, len: usize, f: F) -> Result<R>
where
F: FnOnce(&mut [u8]) -> Result<R>;
}
Expand description
A token to transmit a single network packet.
Required Methods§
sourcefn consume<R, F>(self, timestamp: Instant, len: usize, f: F) -> Result<R>where
F: FnOnce(&mut [u8]) -> Result<R>,
fn consume<R, F>(self, timestamp: Instant, len: usize, f: F) -> Result<R>where
F: FnOnce(&mut [u8]) -> Result<R>,
Consumes the token to send a single network packet.
This method constructs a transmit buffer of size len
and calls the passed
closure f
with a mutable reference to that buffer. The closure should construct
a valid network packet (e.g. an ethernet packet) in the buffer. When the closure
returns, the transmit buffer is sent out.
The timestamp must be a number of milliseconds, monotonically increasing since an arbitrary moment in time, such as system startup.