Struct Destination

Source
pub struct Destination<'a, T, B> { /* private fields */ }
Expand description

Represents the buffer for a host- or guest-initiated stream read.

Implementations§

Source§

impl<'a, T, B> Destination<'a, T, B>

Source

pub fn reborrow(&mut self) -> Destination<'_, T, B>

Reborrow self so it can be used again later.

Source

pub fn take_buffer(&mut self) -> B
where B: Default,

Take the buffer out of self, leaving a default-initialized one in its place.

This can be useful for reusing the previously-stored buffer’s capacity instead of allocating a fresh one.

Source

pub fn set_buffer(&mut self, buffer: B)

Store the specified buffer in self.

Any items contained in the buffer will be delivered to the reader after the StreamProducer::poll_produce call to which this Destination was passed returns (unless overwritten by another call to set_buffer).

If items are stored via this buffer and written via a DirectDestination view of self, then the items in the buffer will be delivered after the ones written using DirectDestination.

Source

pub fn remaining(&self, store: impl AsContextMut) -> Option<usize>

Return the remaining number of items the current read has capacity to accept, if known.

This will return Some(_) if the reader is a guest; it will return None if the reader is the host.

Note that, if this returns None(0), the producer must still attempt to produce at least one item if the value of finish passed to StreamProducer::poll_produce is false. In that case, the reader is effectively asking when the producer will be able to produce items without blocking (or reach a terminal state such as end-of-stream), meaning the next non-zero read must complete without blocking.

Source§

impl<'a, B> Destination<'a, u8, B>

Source

pub fn as_direct<D>( self, store: StoreContextMut<'a, D>, capacity: usize, ) -> DirectDestination<'a, D>

Return a DirectDestination view of self.

If the reader is a guest, this will provide direct access to the guest’s read buffer. If the reader is a host, this will provide access to a buffer which will be delivered to the host before any items stored using Destination::set_buffer.

capacity will only be used if the reader is a host, in which case it will update the length of the buffer, possibly zero-initializing the new elements if the new length is larger than the old length.

Auto Trait Implementations§

§

impl<'a, T, B> Freeze for Destination<'a, T, B>

§

impl<'a, T, B> RefUnwindSafe for Destination<'a, T, B>
where B: RefUnwindSafe,

§

impl<'a, T, B> Send for Destination<'a, T, B>
where B: Send,

§

impl<'a, T, B> Sync for Destination<'a, T, B>
where B: Sync,

§

impl<'a, T, B> Unpin for Destination<'a, T, B>

§

impl<'a, T, B> !UnwindSafe for Destination<'a, T, B>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Pointer = u32

Source§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more