MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / component_and_self

Method component_and_self

crates/wasmtime/src/runtime/vm/component.rs:816–826  ·  view source on GitHub ↗

Same as [`Self::component`] but additionally returns the `Pin<&mut Self>` with the same original lifetime.

(self: Pin<&mut Self>)

Source from the content-addressed store, hash-verified

814 /// Same as [`Self::component`] but additionally returns the
815 /// `Pin<&mut Self>` with the same original lifetime.
816 pub fn component_and_self(self: Pin<&mut Self>) -> (&Component, Pin<&mut Self>) {
817 // SAFETY: this function is projecting both `&Component` and the same
818 // pointer both connected to the same lifetime. This is safe because
819 // it's a contract of `Pin<&mut Self>` that the `Component` field is
820 // never written, meaning it's effectively unsafe to have `&mut
821 // Component` projected from `Pin<&mut Self>`. Consequently it's safe to
822 // have a read-only view of the field while still retaining mutable
823 // access to all other fields.
824 let component = unsafe { &*(&raw const self.component) };
825 (component, self)
826 }
827
828 /// Returns a reference to the resource type information.
829 pub fn resource_types(&self) -> &Arc<TryPrimaryMap<ResourceIndex, ResourceType>> {

Callers 1

newMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected