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§
Source§impl ResourceType
impl ResourceType
Sourcepub 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}.
Sourcepub fn host_dynamic(payload: u32) -> ResourceType
pub fn host_dynamic(payload: u32) -> ResourceType
Creates a new host resource type which is identified by the payload
runtime argument.
The payload argument to this function is an arbitrary 32-bit value
that the host can use to distinguish one resource from another.
A resource type of type ResourceType::host_dynamic(2) will match the
type of the value produced by ResourceDynamic::new_{own,borrow}(_, 2),
for example.
This type of resource is disjoint from all other types of resources. For
example any resource with type ResourceType::host::<u32>() will be a
different type than all types created by this function.
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<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