pub struct FutureReader<T> { /* private fields */ }runtime and component-model and component-model-async only.Expand description
Represents the readable end of a Component Model future.
Note that FutureReader instances must be disposed of using either pipe
or close; otherwise the in-store representation will leak and the writer
end will hang indefinitely. Consider using GuardedFutureReader to
ensure that disposal happens automatically.
Implementations§
Source§impl<T> FutureReader<T>
impl<T> FutureReader<T>
Sourcepub fn new<S: AsContextMut>(
store: S,
producer: impl FutureProducer<S::Data, Item = T>,
) -> Self
pub fn new<S: AsContextMut>( store: S, producer: impl FutureProducer<S::Data, Item = T>, ) -> Self
Create a new future with the specified producer.
Sourcepub fn pipe<S: AsContextMut>(
self,
store: S,
consumer: impl FutureConsumer<S::Data, Item = T> + Unpin,
)where
T: Lift + 'static,
pub fn pipe<S: AsContextMut>(
self,
store: S,
consumer: impl FutureConsumer<S::Data, Item = T> + Unpin,
)where
T: Lift + 'static,
Set the consumer that accepts the result of this future.
Sourcepub fn from_val(
store: impl AsContextMut<Data: Send>,
value: &Val,
) -> Result<Self>
pub fn from_val( store: impl AsContextMut<Data: Send>, value: &Val, ) -> Result<Self>
Attempt to convert the specified Val to a FutureReader.
Sourcepub fn close(&mut self, store: impl AsContextMut)
pub fn close(&mut self, store: impl AsContextMut)
Close this FutureReader, writing the default value.
§Panics
Panics if the store that the [Accessor] is derived from does not own
this future. Usage of this future after calling close will also cause
a panic.
Sourcepub fn close_with(&mut self, accessor: impl AsAccessor)
pub fn close_with(&mut self, accessor: impl AsAccessor)
Convenience method around Self::close.
Sourcepub fn guard<A>(self, accessor: A) -> GuardedFutureReader<T, A>where
A: AsAccessor,
pub fn guard<A>(self, accessor: A) -> GuardedFutureReader<T, A>where
A: AsAccessor,
Returns a GuardedFutureReader which will auto-close this future on
drop and clean it up from the store.
Note that the accessor provided must own this future and is
additionally transferred to the GuardedFutureReader return value.
Trait Implementations§
Source§impl<T> Debug for FutureReader<T>
impl<T> Debug for FutureReader<T>
Source§impl<T, A> From<GuardedFutureReader<T, A>> for FutureReader<T>where
A: AsAccessor,
impl<T, A> From<GuardedFutureReader<T, A>> for FutureReader<T>where
A: AsAccessor,
Source§fn from(guard: GuardedFutureReader<T, A>) -> Self
fn from(guard: GuardedFutureReader<T, A>) -> Self
impl<T: Send + Sync> ComponentType for FutureReader<T>
impl<T: Send + Sync> Lift for FutureReader<T>
impl<T: Send + Sync> Lower for FutureReader<T>
Auto Trait Implementations§
impl<T> Freeze for FutureReader<T>
impl<T> RefUnwindSafe for FutureReader<T>where
T: RefUnwindSafe,
impl<T> Send for FutureReader<T>where
T: Send,
impl<T> Sync for FutureReader<T>where
T: Sync,
impl<T> Unpin for FutureReader<T>where
T: Unpin,
impl<T> UnwindSafe for FutureReader<T>where
T: UnwindSafe,
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