pub struct SplitGrantR<'a, const N: usize> { /* private fields */ }Expand description
This is the Split Reader Grant type given to the user as a view of the logging queue.
It is a re-export of the bbqueue::SplitGrantR type.
A structure representing up to two contiguous regions of memory that may be read from, and potentially “released” (or cleared) from the queue
Implementations§
Source§impl<'a, const N: usize> SplitGrantR<'a, N>
impl<'a, const N: usize> SplitGrantR<'a, N>
Sourcepub fn release(self, used: usize)
pub fn release(self, used: usize)
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.
Sourcepub fn bufs(&self) -> (&[u8], &[u8])
pub fn bufs(&self) -> (&[u8], &[u8])
Obtain access to both inner buffers for reading
use bbqueue::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]);Sourcepub fn bufs_mut(&mut self) -> (&mut [u8], &mut [u8])
pub fn bufs_mut(&mut self) -> (&mut [u8], &mut [u8])
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
Sourcepub fn to_release(&mut self, amt: usize)
pub fn to_release(&mut self, amt: usize)
Configures the amount of bytes to be released on drop.
Sourcepub fn combined_len(&self) -> usize
pub fn combined_len(&self) -> usize
The combined length of both buffers