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.
Trait Implementations§
source§impl<T: WasmResource> Debug for Resource<T>
impl<T: WasmResource> Debug for Resource<T>
source§impl<T: RustResource> Deref for Resource<T>
impl<T: RustResource> Deref for Resource<T>
source§impl<T: RustResource> DerefMut for Resource<T>
impl<T: RustResource> DerefMut for Resource<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Resource<T>where
T: RefUnwindSafe,
impl<T> Send for Resource<T>where
T: Send,
impl<T> Sync for Resource<T>where
T: Sync,
impl<T> Unpin for Resource<T>
impl<T> UnwindSafe for Resource<T>where
T: UnwindSafe,
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