Skip to main content

StreamProducer

Struct StreamProducer 

Source
pub struct StreamProducer<Q>
where Q: BbqHandle,
{ /* private fields */ }
Expand description

A producer handle that may write data into the buffer

Implementations§

Source§

impl<Q> StreamProducer<Q>
where Q: BbqHandle,

Source

pub fn grant_max_remaining( &self, max: usize, ) -> Result<StreamGrantW<Q>, WriteGrantError>

Obtain a grant UP TO the given max size.

If we return a grant, it will have a nonzero amount of space.

If the grant represents LESS than max size, this is due to either:

  • There is less than max free space available in the queue for writing
  • The grant represents the remaining space in the buffer that WOULDN’T cause a wrap-around of the ring buffer

This method will never cause an “early wraparound” of the ring buffer unless there is no capacity without wrapping around. There may still be available writing capacity in the buffer after commiting this write grant, so it may be useful to call grant_max_remaining in a loop until Err(WriteGrantError::InsufficientSize) is returned.

Source

pub fn grant_exact(&self, sz: usize) -> Result<StreamGrantW<Q>, WriteGrantError>

Obtain a grant with EXACTLY sz capacity

Unlike grant_max_remaining, if there is insufficient size at the “tail” of the ring buffer, this method WILL cause a wrap-around to occur to attempt to find the requested write capacity.

Source

pub fn capacity(&self) -> usize

Get the total capacity of the buffer, e.g. how much space is present in Storage

Source§

impl<Q> StreamProducer<Q>

Source

pub async fn wait_grant_max_remaining(&self, max: usize) -> StreamGrantW<Q>

Wait for a grant of any size, up to max, to become available

Source

pub async fn wait_grant_exact(&self, sz: usize) -> StreamGrantW<Q>

Wait for a grant of EXACTLY sz to become available.

If sz exceeds the capacity of the buffer, this method will never return.

Trait Implementations§

Auto Trait Implementations§

§

impl<Q> Freeze for StreamProducer<Q>
where <Q as BbqHandle>::Target: Freeze,

§

impl<Q> RefUnwindSafe for StreamProducer<Q>

§

impl<Q> Sync for StreamProducer<Q>
where <Q as BbqHandle>::Target: Sync,

§

impl<Q> Unpin for StreamProducer<Q>
where <Q as BbqHandle>::Target: Unpin,

§

impl<Q> UnsafeUnpin for StreamProducer<Q>
where <Q as BbqHandle>::Target: UnsafeUnpin,

§

impl<Q> UnwindSafe for StreamProducer<Q>
where <Q as BbqHandle>::Target: UnwindSafe,

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>,

Source§

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>,

Source§

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.