[−][src]Struct bbqueue_ng::SplitGrantR
A structure representing up to two contiguous regions of memory that may be read from, and potentially "released" (or cleared) from the queue
Implementations
impl<'a, const N: usize> SplitGrantR<'a, { N }>
[src]
pub fn release(self, used: usize)
[src]
Release a sequence of bytes from the buffer, allowing the space to be used by later writes. This consumes the grant.
If used
is larger than the given grant, the full grant will
be released.
NOTE: If the thumbv6
feature is selected, this function takes a short critical
section while releasing.
pub fn bufs(&self) -> (&[u8], &[u8])
[src]
Obtain access to both inner buffers for reading
use bbqueue_ng::BBBuffer; // Create and split a new buffer of 6 elements let buffer: BBBuffer<6> = BBBuffer::new(); let (mut prod, mut cons) = buffer.try_split().unwrap(); // Successfully obtain and commit a grant of four bytes let mut grant = prod.grant_max_remaining(4).unwrap(); grant.buf().copy_from_slice(&[1, 2, 3, 4]); grant.commit(4); // Obtain a read grant, and copy to a buffer let mut grant = cons.read().unwrap(); let mut buf = [0u8; 4]; buf.copy_from_slice(grant.buf()); assert_eq!(&buf, &[1, 2, 3, 4]);
pub fn bufs_mut(&mut self) -> (&mut [u8], &mut [u8])
[src]
Obtain mutable access to both parts of the read grant
This is useful if you are performing in-place operations on an incoming packet, such as decryption
pub fn to_release(&mut self, amt: usize)
[src]
Configures the amount of bytes to be released on drop.
pub fn combined_len(&self) -> usize
[src]
The combined length of both buffers
Trait Implementations
impl<'a, const N: usize> Debug for SplitGrantR<'a, N>
[src]
impl<'a, const N: usize> PartialEq<SplitGrantR<'a, N>> for SplitGrantR<'a, N>
[src]
pub fn eq(&self, other: &SplitGrantR<'a, N>) -> bool
[src]
pub fn ne(&self, other: &SplitGrantR<'a, N>) -> bool
[src]
impl<'a, const N: usize> Send for SplitGrantR<'a, { N }>
[src]
impl<'a, const N: usize> StructuralPartialEq for SplitGrantR<'a, N>
[src]
Auto Trait Implementations
impl<'a, const N: usize> !Sync for SplitGrantR<'a, N>
[src]
impl<'a, const N: usize> Unpin for SplitGrantR<'a, N>
[src]
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,
pub 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> Same<T> for T
type Output = T
Should always be Self
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.
pub 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>,