pub struct ResourceType { /* private fields */ }Expand description
Describes the type of a resource. This may either be:
- An abstract guest resource, associated with a component. Abstract resources cannot be used to instantiate any values.
- An instantiated guest resource, associated with an instance. Instantiated guest resources identify resources created by WASM.
- A host resource, which is associated with a native value.
Implementations§
Source§impl ResourceType
impl ResourceType
Sourcepub fn new<T: 'static + Send + Sync + Sized>(
name: Option<TypeIdentifier>,
) -> Self
pub fn new<T: 'static + Send + Sync + Sized>( name: Option<TypeIdentifier>, ) -> Self
Creates a new host resource for storing values of the given type. Note that multiple
resource types may be created for the same T, and they will be distinct.
Sourcepub fn with_destructor<T: 'static + Send + Sync + Sized, C: AsContextMut>(
ctx: C,
name: Option<TypeIdentifier>,
destructor: impl 'static + Send + Sync + Fn(StoreContextMut<'_, C::UserState, C::Engine>, T) -> Result<()>,
) -> Result<Self>
pub fn with_destructor<T: 'static + Send + Sync + Sized, C: AsContextMut>( ctx: C, name: Option<TypeIdentifier>, destructor: impl 'static + Send + Sync + Fn(StoreContextMut<'_, C::UserState, C::Engine>, T) -> Result<()>, ) -> Result<Self>
Creates a new host resource for storing values of the given type. Additionally,
adds a destructor that is called when the resource is dropped. Note that multiple
resource types may be created for the same T, and they will be distinct.
Sourcepub fn name(&self) -> Option<&TypeIdentifier>
pub fn name(&self) -> Option<&TypeIdentifier>
Gets the name of this type, if any.
Trait Implementations§
Source§impl Clone for ResourceType
impl Clone for ResourceType
Source§fn clone(&self) -> ResourceType
fn clone(&self) -> ResourceType
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 ResourceType
impl Debug for ResourceType
Source§impl Hash for ResourceType
impl Hash for ResourceType
Source§impl PartialEq for ResourceType
impl PartialEq for ResourceType
impl Eq for ResourceType
Auto Trait Implementations§
impl Freeze for ResourceType
impl !RefUnwindSafe for ResourceType
impl Send for ResourceType
impl Sync for ResourceType
impl Unpin for ResourceType
impl !UnwindSafe for ResourceType
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.