Skip to main content

Writer

Trait Writer 

Source
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§

Source

fn send_frame(&mut self, data: &[u8]) -> Result<()>

Provided Methods§

Source

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.

Source

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.

Source

fn send_shared_deferred(&mut self, data: &PacketBytes) -> Result<()>

Deferred send of shared frame bytes; writers with a worker queue may retain the shared buffer instead of copying it.

Source

fn wake(&mut self)

Wake a worker postponed by Writer::send_frame_deferred.

Source

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.

Source

fn send_frames(&mut self, frames: &[FrameBytes]) -> Result<()>

Source

fn flush(&mut self) -> Result<()>

Resume bytes accepted by a previous call that returned WouldBlock.

Source

fn egress_control(&self) -> Option<EgressControl>

Share an exact byte admission budget with the async producer when this writer uses dataplane egress control.

Source

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.

Source

fn shutdown(&mut self)

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§