pub struct ResourceType { /* private fields */ }
runtime
and component-model
only.Expand description
Representation of a resource type in the component model.
Resources are currently always represented as 32-bit integers but they have unique types across instantiations and the host. For example instantiating the same component twice means that defined resource types in the component will all be different. Values of this type can be compared to see if resources have the same type.
Resource types can also be defined on the host in addition to guests. On the
host resource types are tied to a T
, an arbitrary Rust type. Two host
resource types are the same if they point to the same T
.
Implementations§
Source§impl ResourceType
impl ResourceType
Sourcepub fn host<T: 'static>() -> ResourceType
pub fn host<T: 'static>() -> ResourceType
Creates a new host resource type corresponding to T
.
Note that T
is a mostly a phantom type parameter here. It does not
need to reflect the actual storage of the resource T
. For example this
is valid:
use wasmtime::component::ResourceType;
struct Foo;
let ty = ResourceType::host::<Foo>();
A resource type of type ResourceType::host::<T>()
will match the type
of the value produced by Resource::<T>::new_{own,borrow}
.
Trait Implementations§
Source§impl Clone for ResourceType
impl Clone for ResourceType
Source§fn clone(&self) -> ResourceType
fn clone(&self) -> ResourceType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ResourceType
impl Debug for ResourceType
Source§impl PartialEq for ResourceType
impl PartialEq for ResourceType
impl Copy for ResourceType
impl Eq for ResourceType
impl StructuralPartialEq 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
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