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

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.