vmbus_ring

Trait RingMem

Source
pub trait RingMem: Send {
    // Required methods
    fn control(&self) -> &[AtomicU32; 32];
    fn read_at(&self, addr: usize, data: &mut [u8]);
    fn write_at(&self, addr: usize, data: &[u8]);
    fn len(&self) -> usize;

    // Provided methods
    fn read_aligned(&self, addr: usize, data: &mut [u8]) { ... }
    fn write_aligned(&self, addr: usize, data: &[u8]) { ... }
}
Expand description

A trait for memory backing a ring buffer.

Required Methods§

Source

fn control(&self) -> &[AtomicU32; 32]

Returns the control page.

Source

fn read_at(&self, addr: usize, data: &mut [u8])

Reads from the data portion of the ring, wrapping (once) at the end of the ring. Precondition: addr + data.len() <= self.len() * 2.

Source

fn write_at(&self, addr: usize, data: &[u8])

Writes to the data portion of the ring, wrapping (once) at the end of the ring. Precondition: addr + data.len() <= self.len() * 2.

Source

fn len(&self) -> usize

Returns the length of the ring in bytes.

Provided Methods§

Source

fn read_aligned(&self, addr: usize, data: &mut [u8])

Reads from the data portion of the ring, as in RingMem::read_at. addr and data.len() must be multiples of 8.

read_at may be faster for large or variable-sized reads.

Source

fn write_aligned(&self, addr: usize, data: &[u8])

Writes to the data portion of the ring, as in RingMem::write_at. addr and data.len() must be multiples of 8.

write_at may be faster for large or variable-sized writes.

Implementations on Foreign Types§

Source§

impl<T: RingMem + Sync> RingMem for &T

Implementation of RingMem for references. Useful for tests.

Source§

fn control(&self) -> &[AtomicU32; 32]

Source§

fn read_at(&self, addr: usize, data: &mut [u8])

Source§

fn write_at(&self, addr: usize, data: &[u8])

Source§

fn len(&self) -> usize

Source§

fn read_aligned(&self, addr: usize, data: &mut [u8])

Source§

fn write_aligned(&self, addr: usize, data: &[u8])

Implementors§