Struct FutureAny
pub struct FutureAny { /* private fields */ }Expand description
Represents a type-erased component model future.
This type is similar to ResourceAny
where it’s a static guarantee that it represents a component model
future, but it does not contain any information about the underlying type
that is associated with this future. This is intended to be used in
“dynamically typed” situations where embedders may not know ahead of time
the type of a future being used by component that is loaded.
§Closing futures
A FutureAny represents a resource that is owned by a Store. Proper
disposal of a future requires invoking the FutureAny::close method to
ensure that this handle does not leak. If FutureAny::close is not
called then memory will not be leaked once the owning Store is dropped,
but the resource handle will be leaked until the Store is dropped.
Note that special care should be taken when handling FutureAny in async
functions. In this scenario an async host function can be cancelled
(dropped) at any time and if a FutureAny it holds isn’t closed then the
future will be leaked within the store until the store is dropped.
§Cloning
Cloning a FutureAny does not duplicate the underlying future: all clones
refer to the same read end, whose ownership can only be transferred once.
After one clone has been lowered into a guest, piped, or closed, attempting
any of those with another clone returns an error.
Implementations§
§impl FutureAny
impl FutureAny
pub fn try_into_future_reader<T>(self) -> Result<FutureReader<T>, Error>where
T: ComponentType + 'static,
pub fn try_into_future_reader<T>(self) -> Result<FutureReader<T>, Error>where
T: ComponentType + 'static,
Attempts to convert this FutureAny to a FutureReader<T>
with a statically known type.
§Errors
This function will return an error if T does not match the type of
value on this future.
pub fn try_from_future_reader<T>(
store: impl AsContextMut,
reader: FutureReader<T>,
) -> Result<FutureAny, Error>where
T: ComponentType + 'static,
pub fn try_from_future_reader<T>(
store: impl AsContextMut,
reader: FutureReader<T>,
) -> Result<FutureAny, Error>where
T: ComponentType + 'static,
pub fn close(&mut self, store: impl AsContextMut) -> Result<(), Error>
pub fn close(&mut self, store: impl AsContextMut) -> Result<(), Error>
Close this FutureAny.
This will close this future and cause any write that happens later to
returned DROPPED.
§Errors
Returns an error if this future has already been closed or otherwise
transferred (e.g. lowered into a guest), or if it does not belong to
store.
Trait Implementations§
impl ComponentType for FutureAny
impl Lift for FutureAny
impl Lower for FutureAny
impl StructuralPartialEq for FutureAny
Auto Trait Implementations§
impl Freeze for FutureAny
impl RefUnwindSafe for FutureAny
impl Send for FutureAny
impl Sync for FutureAny
impl Unpin for FutureAny
impl UnsafeUnpin for FutureAny
impl UnwindSafe for FutureAny
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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