pub struct FutureReader<T> { /* private fields */ }
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>(
instance: Instance,
store: S,
producer: impl FutureProducer<<S as AsContext>::Data, Item = T>,
) -> FutureReader<T>
pub fn new<S>( instance: Instance, store: S, producer: impl FutureProducer<<S as AsContext>::Data, Item = T>, ) -> FutureReader<T>
Create a new future with the specified producer.
Sourcepub fn pipe<S>(
self,
store: S,
consumer: impl FutureConsumer<<S as AsContext>::Data, Item = T> + Unpin,
)where
S: AsContextMut,
T: Lift + 'static,
pub fn pipe<S>(
self,
store: S,
consumer: impl FutureConsumer<<S as AsContext>::Data, Item = T> + Unpin,
)where
S: AsContextMut,
T: Lift + 'static,
Set the consumer that accepts the result of this future.
Sourcepub fn from_val(
store: impl AsContextMut,
instance: Instance,
value: &Val,
) -> Result<FutureReader<T>, Error>
pub fn from_val( store: impl AsContextMut, instance: Instance, value: &Val, ) -> Result<FutureReader<T>, Error>
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>) -> FutureReader<T>
fn from(guard: GuardedFutureReader<T, A>) -> FutureReader<T>
impl<T> ComponentType for FutureReader<T>
impl<T> Lift for FutureReader<T>
impl<T> 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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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