Struct bbqueue::SplitGrantR [−][src]
pub struct SplitGrantR<'a, const N: usize> { /* fields omitted */ }
Expand description
A structure representing up to two contiguous regions of memory that may be read from, and potentially “released” (or cleared) from the queue
Implementations
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.
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]);
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
Configures the amount of bytes to be released on drop.
The combined length of both buffers
Trait Implementations
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.