pub struct FutureWriter<T> { /* private fields */ }runtime and component-model and component-model-async only.Expand description
Represents the writable end of a Component Model future.
Note that FutureWriter instances must be disposed of using either write
or close; otherwise the in-store representation will leak and the reader
end will hang indefinitely. Consider using GuardedFutureWriter to
ensure that disposal happens automatically.
Implementations§
Source§impl<T> FutureWriter<T>
impl<T> FutureWriter<T>
Sourcepub async fn write(self, accessor: impl AsAccessor, value: T) -> bool
pub async fn write(self, accessor: impl AsAccessor, value: T) -> bool
Write the specified value to this future.
The returned Future will yield true if the read end accepted the
value; otherwise it will return false, meaning the read end was dropped
before the value could be delivered.
§Panics
Panics if the store that the [Accessor] is derived from does not own
this future.
Sourcepub async fn watch_reader(&mut self, accessor: impl AsAccessor)
pub async fn watch_reader(&mut self, accessor: impl AsAccessor)
Wait for the read end of this future is dropped.
The [Accessor] provided can be acquired from Instance::run_concurrent or
from within a host function for example.
§Panics
Panics if the store that the [Accessor] is derived from does not own
this future.
Sourcepub fn close(&mut self, store: impl AsContextMut)
pub fn close(&mut self, store: impl AsContextMut)
Close this FutureWriter, 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) -> GuardedFutureWriter<T, A>
pub fn guard<A>(self, accessor: A) -> GuardedFutureWriter<T, A>
Returns a GuardedFutureWriter 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 GuardedFutureWriter return value.
Trait Implementations§
Source§impl<T, A> From<GuardedFutureWriter<T, A>> for FutureWriter<T>
impl<T, A> From<GuardedFutureWriter<T, A>> for FutureWriter<T>
Source§fn from(guard: GuardedFutureWriter<T, A>) -> Self
fn from(guard: GuardedFutureWriter<T, A>) -> Self
Auto Trait Implementations§
impl<T> Freeze for FutureWriter<T>
impl<T> RefUnwindSafe for FutureWriter<T>
impl<T> Send for FutureWriter<T>
impl<T> Sync for FutureWriter<T>
impl<T> Unpin for FutureWriter<T>
impl<T> UnsafeUnpin for FutureWriter<T>
impl<T> UnwindSafe for FutureWriter<T>
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