Struct wit_bindgen::Resource
source · pub struct Resource<T: WasmResource> { /* private fields */ }
Expand description
A type which represents a component model resource, either imported or exported into this component.
This is a low-level wrapper which handles the lifetime of the resource
(namely this has a destructor). The T
provided defines the component model
intrinsics that this wrapper uses.
One of the chief purposes of this type is to provide Deref
implementations
to access the underlying data when it is owned.
This type is primarily used in generated code for exported and imported resources.
Implementations§
source§impl<T: WasmResource> Resource<T>
impl<T: WasmResource> Resource<T>
sourcepub fn new(val: T) -> Resource<T>where
T: RustResource,
pub fn new(val: T) -> Resource<T>where
T: RustResource,
Creates a new Rust-defined resource from the underlying representation
T
.
This will move T
onto the heap to create a single pointer to represent
it which is then wrapped up in a component model resource.
sourcepub fn into_inner(resource: Self) -> Twhere
T: RustResource,
pub fn into_inner(resource: Self) -> Twhere
T: RustResource,
Takes back ownership of the object, dropping the resource handle.