[][src]Struct kernel::common::leasable_buffer::LeasableBuffer

pub struct LeasableBuffer<'a, T> {
    internal: &'a mut [T],
    active_range: Range<usize>,

Leasable Buffer which can be used to pass a section of a larger buffer but still get the entire buffer back in a callback


internal: &'a mut [T]active_range: Range<usize>


impl<'a, T> LeasableBuffer<'a, T>[src]

pub fn new(buffer: &'a mut [T]) -> Self[src]

Create a leasable buffer from a passed reference to a raw buffer

pub fn take(self) -> &'a mut [T][src]

Retrieve the raw buffer used to create the LeasableBuffer. Consumes the LeasableBuffer.

pub fn reset(&mut self)[src]

Resets the LeasableBuffer to its full size, making the entire buffer accessible again. Typically this would be called once a sliced LeasableBuffer is returned through a callback.

fn active_slice(&self) -> &[T][src]

pub fn len(&self) -> usize[src]

Returns the length of the currently accessible portion of the LeasableBuffer

pub fn as_ptr(&self) -> *const T[src]

Returns a pointer to the currently accessible portion of the LeasableBuffer

pub fn slice<R: RangeBounds<usize>>(&mut self, range: R)[src]

Reduces the range of the LeasableBuffer that is accessible. This should be called whenever an upper layer wishes to pass only a portion of a larger buffer down to a lower layer. For example: if the application layer has a 1500 byte packet buffer, but wishes to send a 250 byte packet, the upper layer should slice the LeasableBuffer down to its first 250 bytes before passing it down.

Trait Implementations

impl<'a, T, I> Index<I> for LeasableBuffer<'a, T> where
    I: SliceIndex<[T]>, 

type Output = <I as SliceIndex<[T]>>::Output

The returned type after indexing.

impl<'a, T, I> IndexMut<I> for LeasableBuffer<'a, T> where
    I: SliceIndex<[T]>, 

Auto Trait Implementations

impl<'a, T> Unpin for LeasableBuffer<'a, T>

impl<'a, T> Send for LeasableBuffer<'a, T> where
    T: Send

impl<'a, T> Sync for LeasableBuffer<'a, T> where
    T: Sync

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> Any for T where
    T: 'static + ?Sized