[−][src]Struct bbqueue_ng::GrantW
A structure representing a contiguous region of memory that may be written to, and potentially "committed" to the queue.
NOTE: If the grant is dropped without explicitly commiting
the contents, or by setting a the number of bytes to
automatically be committed with to_commit()
, then no bytes
will be comitted for writing.
If the thumbv6
feature is selected, dropping the grant
without committing it takes a short critical section,
Implementations
impl<'a, const N: usize> GrantW<'a, { N }>
[src]
pub fn commit(self, used: usize)
[src]
Finalizes a writable grant given by grant()
or grant_max()
.
This makes the data available to be read via read()
. This consumes
the grant.
If used
is larger than the given grant, the maximum amount will
be commited
NOTE: If the thumbv6
feature is selected, this function takes a short critical
section while committing.
pub fn buf(&mut self) -> &mut [u8]
[src]
Obtain access to the inner buffer for writing
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);
pub unsafe fn as_static_mut_buf(&mut self) -> &'static mut [u8]
[src]
Sometimes, it's not possible for the lifetimes to check out. For example,
if you need to hand this buffer to a function that expects to receive a
&'static mut [u8]
, it is not possible for the inner reference to outlive the
grant itself.
You MUST guarantee that in no cases, the reference that is returned here outlives the grant itself. Once the grant has been released, referencing the data contained WILL cause undefined behavior.
Additionally, you must ensure that a separate reference to this data is not created
to this data, e.g. using DerefMut
or the buf()
method of this grant.
pub fn to_commit(&mut self, amt: usize)
[src]
Configures the amount of bytes to be commited on drop.
Trait Implementations
impl<'a, const N: usize> Debug for GrantW<'a, N>
[src]
impl<'a, const N: usize> Deref for GrantW<'a, N>
[src]
impl<'a, const N: usize> DerefMut for GrantW<'a, N>
[src]
impl<'a, const N: usize> Drop for GrantW<'a, N>
[src]
impl<'a, const N: usize> PartialEq<GrantW<'a, N>> for GrantW<'a, N>
[src]
pub fn eq(&self, other: &GrantW<'a, N>) -> bool
[src]
pub fn ne(&self, other: &GrantW<'a, N>) -> bool
[src]
impl<'a, const N: usize> Send for GrantW<'a, { N }>
[src]
impl<'a, const N: usize> StructuralPartialEq for GrantW<'a, N>
[src]
Auto Trait Implementations
impl<'a, const N: usize> !Sync for GrantW<'a, N>
[src]
impl<'a, const N: usize> Unpin for GrantW<'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>,