pub struct Destination<'a, T, B> { /* private fields */ }runtime and component-model and component-model-async only.Expand description
Represents the buffer for a host- or guest-initiated stream read.
Implementations§
Source§impl<'a, T, B> Destination<'a, T, B>
impl<'a, T, B> Destination<'a, T, B>
Sourcepub fn reborrow(&mut self) -> Destination<'_, T, B>
pub fn reborrow(&mut self) -> Destination<'_, T, B>
Reborrow self so it can be used again later.
Sourcepub fn take_buffer(&mut self) -> Bwhere
B: Default,
pub fn take_buffer(&mut self) -> Bwhere
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.
Sourcepub fn set_buffer(&mut self, buffer: B)
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.
Sourcepub fn remaining(&self, store: impl AsContextMut) -> Option<usize>
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 this can return Some(0). This means that the guest is
attempting to perform a zero-length read which typically means that it’s
trying to wait for this stream to be ready-to-read but is not actually
ready to receive the items yet. The host in this case is allowed to
either block waiting for readiness or immediately complete the
operation. The guest is expected to handle both cases. Some more
discussion about this case can be found in the discussion of “Stream
Readiness” in the component-model repo.
Source§impl<'a, B> Destination<'a, u8, B>
impl<'a, B> Destination<'a, u8, B>
Sourcepub fn as_direct<D>(
self,
store: StoreContextMut<'a, D>,
capacity: usize,
) -> DirectDestination<'a, D>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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