pub trait Writer: Send {
// Required method
fn send_frame(&mut self, data: &[u8]) -> Result<()>;
// Provided methods
fn send_frame_confirmed(&mut self, data: &[u8]) -> Result<()> { ... }
fn send_frame_deferred(&mut self, data: &[u8]) -> Result<()> { ... }
fn send_shared_deferred(&mut self, data: &PacketBytes) -> Result<()> { ... }
fn wake(&mut self) { ... }
fn flush_pending(&mut self) { ... }
fn send_frames(&mut self, frames: &[FrameBytes]) -> Result<()> { ... }
fn flush(&mut self) -> Result<()> { ... }
fn egress_control(&self) -> Option<EgressControl> { ... }
fn loop_socket(&self) -> Option<RawFd> { ... }
fn shutdown(&mut self) { ... }
}Expand description
Writable end of an interface. Held by the driver.
Each implementation wraps a socket + framing.
Required Methods§
fn send_frame(&mut self, data: &[u8]) -> Result<()>
Provided Methods§
Sourcefn send_frame_confirmed(&mut self, data: &[u8]) -> Result<()>
fn send_frame_confirmed(&mut self, data: &[u8]) -> Result<()>
Write one frame without silently dropping it. WouldBlock means the
frame was accepted and flush must finish it before success is reported.
Writers with intentional drop policies must override this method.
Sourcefn send_frame_deferred(&mut self, data: &[u8]) -> Result<()>
fn send_frame_deferred(&mut self, data: &[u8]) -> Result<()>
Like Writer::send_frame, but a writer with its own worker may
postpone waking it until Writer::wake. The driver uses this for
forwarded frames and wakes each touched writer once per event batch.
Deferred send of shared frame bytes; writers with a worker queue may retain the shared buffer instead of copying it.
Sourcefn wake(&mut self)
fn wake(&mut self)
Wake a worker postponed by Writer::send_frame_deferred.
Sourcefn flush_pending(&mut self)
fn flush_pending(&mut self)
Write out what a driver-run writer has buffered (see loop_writer).
The driver calls this on every writer before it waits for more
input, so frames from one pass leave in as few writes as possible.
fn send_frames(&mut self, frames: &[FrameBytes]) -> Result<()>
Sourcefn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Resume bytes accepted by a previous call that returned WouldBlock.
Sourcefn egress_control(&self) -> Option<EgressControl>
fn egress_control(&self) -> Option<EgressControl>
Share an exact byte admission budget with the async producer when this writer uses dataplane egress control.
Sourcefn loop_socket(&self) -> Option<RawFd>
fn loop_socket(&self) -> Option<RawFd>
A stream socket the driver may write directly, without a worker
thread (see loop_writer). Writers returning one must only frame
with HDLC and write the result to this descriptor.
fn shutdown(&mut self)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".