BufferAccess

Trait BufferAccess 

Source
pub trait BufferAccess {
    // Required methods
    fn guest_memory(&self) -> &GuestMemory;
    fn write_data(&mut self, id: RxId, data: &[u8]);
    fn push_guest_addresses(&self, id: RxId, buf: &mut Vec<RxBufferSegment>);
    fn capacity(&self, id: RxId) -> u32;
    fn write_header(&mut self, id: RxId, metadata: &RxMetadata);

    // Provided method
    fn write_packet(&mut self, id: RxId, metadata: &RxMetadata, data: &[u8]) { ... }
}
Expand description

Frontend-owned access to guest receive buffers.

Each frontend implements this trait to map RxId values to guest memory regions. The backend writes received packet data and metadata through these methods.

The frontend owns the BufferAccess and passes &mut references to Queue methods. This means no Arc/Mutex is needed between the frontend and backend for buffer access—the borrow checker enforces exclusive access statically.

Required Methods§

Source

fn guest_memory(&self) -> &GuestMemory

The associated guest memory accessor.

Source

fn write_data(&mut self, id: RxId, data: &[u8])

Writes data to the specified buffer.

Source

fn push_guest_addresses(&self, id: RxId, buf: &mut Vec<RxBufferSegment>)

Appends the guest address segments for the specified buffer to buf.

Callers must clear buf before calling if they do not want segments from a previous call to be retained.

Source

fn capacity(&self, id: RxId) -> u32

The capacity of the specified buffer in bytes.

Source

fn write_header(&mut self, id: RxId, metadata: &RxMetadata)

Sets the packet metadata for the receive.

Provided Methods§

Source

fn write_packet(&mut self, id: RxId, metadata: &RxMetadata, data: &[u8])

Writes the packet header and data in a single call.

Implementors§