[−][src]Struct vmcircbuf::Buffer
A raw circular buffer of bytes. The buffer holds exactly size many
bytes, and any at most wrap many bytes can be accessed as a continuos
slice where the end wraps over to the beginning. This trick is performed
with virtual memory, the same physical pages are mapped both at the start
of an buffer and after the end of the buffer.
Methods
impl Buffer[src]
pub fn page_size() -> Result<usize, Error>[src]
Returns the page size of the underlying operating system.
pub fn new(size: usize, wrap: usize) -> Result<Buffer, Error>[src]
Creates a new circular buffer with the given size and wrap. The
returned size and wrap will be rounded up to an integer multiple
of the page size. The wrap value cannot be larger than size, and
both can be zero to get the page size.
pub fn size(&self) -> usize[src]
Returns the size of the circular buffer.
pub fn wrap(&self) -> usize[src]
Returns the wrap of the circular buffer.
pub fn slice(&self, start: usize, count: usize) -> &[u8][src]
Returns an immutable slice of the circular buffer starting at start
and containing count many elements. Note, that start + count
cannot be larger than size + wrap. If start + count is bigger
than size, then the returned slice will magically wrap over
to the beginning of the buffer.
pub fn slice_mut(&mut self, start: usize, count: usize) -> &mut [u8][src]
This is the mutable analog of the slice method.
pub unsafe fn slice_unchecked(&self, start: usize, count: usize) -> &[u8][src]
This is the unsafe version of the slice method.
Safety
Make sure that start + count <= size + wrap before
calling this method.
pub unsafe fn slice_mut_unchecked(
&mut self,
start: usize,
count: usize
) -> &mut [u8][src]
&mut self,
start: usize,
count: usize
) -> &mut [u8]
This is the unsafe version of the slice_mut method.
Safety
Make sure that start + count <= size + wrap before
calling this method.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,