Struct ResourceType
pub struct ResourceType { /* private fields */ }
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§
§impl ResourceType
impl ResourceType
pub fn host<T>() -> ResourceTypewhere
T: 'static,
pub fn host<T>() -> ResourceTypewhere
T: 'static,
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§
§impl Clone for ResourceType
impl Clone for ResourceType
§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 more§impl Debug for ResourceType
impl Debug for ResourceType
§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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§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.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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