pub trait Client {
// Required methods
fn driver(&self) -> &dyn Driver;
fn recv(&mut self, data: &[u8], checksum: &ChecksumState);
fn rx_mtu(&mut self) -> usize;
// Provided method
fn recv_segments(&mut self, segments: &[&[u8]], checksum: &ChecksumState) { ... }
}Expand description
A consomme client.
Required Methods§
Sourcefn driver(&self) -> &dyn Driver
fn driver(&self) -> &dyn Driver
Gets the driver to use for handling new connections.
TODO: generalize connection creation to allow pluggable model (not just OS sockets) and remove this.
Sourcefn recv(&mut self, data: &[u8], checksum: &ChecksumState)
fn recv(&mut self, data: &[u8], checksum: &ChecksumState)
Transmits a packet to the client.
If checksum.ipv4, checksum.tcp, or checksum.udp are set, then the
packet contains an IPv4 header, TCP header, and/or UDP header with a
valid checksum.
TODO: support >MTU sized packets (RSC/LRO/GRO).
Provided Methods§
Sourcefn recv_segments(&mut self, segments: &[&[u8]], checksum: &ChecksumState)
fn recv_segments(&mut self, segments: &[&[u8]], checksum: &ChecksumState)
Transmits a packet whose bytes are provided as multiple discontiguous segments, delivered in order as a single logical packet.
This lets callers avoid linearizing a frame into a scratch buffer when
its payload is not contiguous (for example, a header segment followed by
TCP window bytes that wrap a ring buffer). The checksum argument has
the same meaning as for Client::recv.
The default implementation copies the segments into a contiguous buffer
and forwards to Client::recv. Clients that can write discontiguous
data directly to the guest should override this to eliminate the copy.