Struct abi::bbqueue_ipc::bbbuffer::Producer

source ·
pub struct Producer<'a> {
    bbq: NonNull<BBBuffer>,
    pd: PhantomData<&'a ()>,
}
Expand description

Producer is the primary interface for pushing data into a BBBuffer. There are various methods for obtaining a grant to write to the buffer, with different potential tradeoffs. As all grants are required to be a contiguous range of data, different strategies are sometimes useful when making the decision between maximizing usage of the buffer, and ensuring a given grant is successful.

As a short summary of currently possible grants:

  • grant_exact(N)
    • User will receive a grant sz == N (or receive an error)
    • This may cause a wraparound if a grant of size N is not available at the end of the ring.
    • If this grant caused a wraparound, the bytes that were “skipped” at the end of the ring will not be available until the reader reaches them, regardless of whether the grant commited any data or not.
    • Maximum possible waste due to skipping: N - 1 bytes
  • grant_max_remaining(N)
    • User will receive a grant 0 < sz <= N (or receive an error)
    • This will only cause a wrap to the beginning of the ring if exactly zero bytes are available at the end of the ring.
    • Maximum possible waste due to skipping: 0 bytes

See this github issue for a discussion of grant methods that could be added in the future.

Fields§

§bbq: NonNull<BBBuffer>§pd: PhantomData<&'a ()>

Implementations§

source§

impl<'a> Producer<'a>

source

pub fn grant_exact(&self, sz: usize) -> Result<GrantW<'a>>

Request a writable, contiguous section of memory of exactly sz bytes. If the buffer size requested is not available, an error will be returned.

This method may cause the buffer to wrap around early if the requested space is not available at the end of the buffer, but is available at the beginning

source

pub fn grant_max_remaining(&self, sz: usize) -> Result<GrantW<'a>>

Request a writable, contiguous section of memory of up to sz bytes. If a buffer of size sz is not available without wrapping, but some space (0 < available < sz) is available without wrapping, then a grant will be given for the remaining size at the end of the buffer. If no space is available for writing, an error will be returned.

Trait Implementations§

source§

impl<'a> Send for Producer<'a>

source§

impl<'a> Sync for Producer<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Producer<'a>

§

impl<'a> RefUnwindSafe for Producer<'a>

§

impl<'a> Unpin for Producer<'a>

§

impl<'a> UnwindSafe for Producer<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.