Struct StreamAny
pub struct StreamAny { /* private fields */ }Expand description
Represents a type-erased component model stream.
This type is similar to ResourceAny
where it’s a static guarantee that it represents a component model
stream, but it does not contain any information about the underlying type
that is associated with this stream. This is intended to be used in
“dynamically typed” situations where embedders may not know ahead of time
the type of a stream being used by component that is loaded.
§Closing streams
A StreamAny represents a resource that is owned by a Store. Proper
disposal of a stream requires invoking the StreamAny::close method to
ensure that this handle does not leak. If StreamAny::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.
Implementations§
§impl StreamAny
impl StreamAny
pub fn try_into_stream_reader<T>(self) -> Result<StreamReader<T>, Error>where
T: ComponentType + 'static,
pub fn try_into_stream_reader<T>(self) -> Result<StreamReader<T>, Error>where
T: ComponentType + 'static,
Attempts to convert this StreamAny to a StreamReader<T>
with a statically known type.
§Errors
This function will return an error if T does not match the type of
value on this stream.
pub fn try_from_stream_reader<T>(
store: impl AsContextMut,
reader: StreamReader<T>,
) -> Result<StreamAny, Error>where
T: ComponentType + 'static,
pub fn try_from_stream_reader<T>(
store: impl AsContextMut,
reader: StreamReader<T>,
) -> Result<StreamAny, Error>where
T: ComponentType + 'static,
pub fn close(&mut self, store: impl AsContextMut)
pub fn close(&mut self, store: impl AsContextMut)
Close this StreamAny.
This will close this stream and cause any write that happens later to
returned DROPPED.
§Panics
Panics if the store does not own this stream. Usage of this stream
after calling close will also cause a panic.
Trait Implementations§
impl ComponentType for StreamAny
impl Lift for StreamAny
impl Lower for StreamAny
impl StructuralPartialEq for StreamAny
Auto Trait Implementations§
impl Freeze for StreamAny
impl RefUnwindSafe for StreamAny
impl Send for StreamAny
impl Sync for StreamAny
impl Unpin for StreamAny
impl UnwindSafe for StreamAny
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