Struct wasm_component_layer::ResourceOwn
source · pub struct ResourceOwn { /* private fields */ }
Expand description
Represents a resource that is owned by the host.
Implementations§
source§impl ResourceOwn
impl ResourceOwn
sourcepub fn new<T: 'static + Send + Sync + Sized>(
ctx: impl AsContextMut,
value: T,
ty: ResourceType
) -> Result<Self>
pub fn new<T: 'static + Send + Sync + Sized>( ctx: impl AsContextMut, value: T, ty: ResourceType ) -> Result<Self>
Creates a new resource for the given value. The value must match the resource type, which must be a host resource type.
sourcepub fn borrow(&self, ctx: impl AsContextMut) -> Result<ResourceBorrow>
pub fn borrow(&self, ctx: impl AsContextMut) -> Result<ResourceBorrow>
Creates a borrow of this owned resource. The resulting borrow must be manually released via ResourceBorrow::drop
afterward.
sourcepub fn rep<'a, T: 'static + Send + Sync, S, E: WasmEngine>(
&self,
ctx: &'a StoreContext<'_, S, E>
) -> Result<&'a T>
pub fn rep<'a, T: 'static + Send + Sync, S, E: WasmEngine>( &self, ctx: &'a StoreContext<'_, S, E> ) -> Result<&'a T>
Gets the internal representation of this resource. Fails if this is not a host resource, or if the resource was already dropped.
sourcepub fn ty(&self) -> ResourceType
pub fn ty(&self) -> ResourceType
Gets the type of this value.
sourcepub fn take<T: 'static + Send + Sync>(
&self,
ctx: impl AsContextMut
) -> Result<()>
pub fn take<T: 'static + Send + Sync>( &self, ctx: impl AsContextMut ) -> Result<()>
Removes this resource from the context without invoking the destructor, and returns the value. Fails if this is not a host resource, or if the resource is borrowed.
sourcepub fn drop(&self, ctx: impl AsContextMut) -> Result<()>
pub fn drop(&self, ctx: impl AsContextMut) -> Result<()>
Drops this resource and invokes the destructor, removing it from the context. Fails if the resource is borrowed or already destroyed.
Trait Implementations§
source§impl Clone for ResourceOwn
impl Clone for ResourceOwn
source§fn clone(&self) -> ResourceOwn
fn clone(&self) -> ResourceOwn
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ResourceOwn
impl Debug for ResourceOwn
Auto Trait Implementations§
impl Freeze for ResourceOwn
impl !RefUnwindSafe for ResourceOwn
impl Send for ResourceOwn
impl Sync for ResourceOwn
impl Unpin for ResourceOwn
impl !UnwindSafe for ResourceOwn
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
Mutably borrows from an owned value. Read more