Struct wasm_compose::graph::Component
source · pub struct Component<'a> { /* private fields */ }
Expand description
Represents a component in a composition graph.
Implementations§
source§impl<'a> Component<'a>
impl<'a> Component<'a>
sourcepub fn from_file(name: &str, path: impl AsRef<Path>) -> Result<Self>
pub fn from_file(name: &str, path: impl AsRef<Path>) -> Result<Self>
Constructs a new component from reading the given file.
sourcepub fn from_bytes(
name: impl Into<String>,
bytes: impl Into<Cow<'a, [u8]>>
) -> Result<Self>
pub fn from_bytes( name: impl Into<String>, bytes: impl Into<Cow<'a, [u8]>> ) -> Result<Self>
Constructs a new component from the given bytes.
sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Gets the name of the component.
Names must be unique within a composition graph.
sourcepub fn path(&self) -> Option<&Path>
pub fn path(&self) -> Option<&Path>
Gets the path of the component.
Returns None
if the component was not loaded from a file.
sourcepub fn export(
&self,
index: impl Into<ExportIndex>
) -> Option<(&str, ComponentExternalKind, u32)>
pub fn export( &self, index: impl Into<ExportIndex> ) -> Option<(&str, ComponentExternalKind, u32)>
Gets an export from the component for the given export index.
sourcepub fn export_by_name(
&self,
name: &str
) -> Option<(ExportIndex, ComponentExternalKind, u32)>
pub fn export_by_name( &self, name: &str ) -> Option<(ExportIndex, ComponentExternalKind, u32)>
Gets an export from the component for the given export name.
sourcepub fn exports(
&self
) -> impl ExactSizeIterator<Item = (ExportIndex, &str, ComponentExternalKind, u32)>
pub fn exports( &self ) -> impl ExactSizeIterator<Item = (ExportIndex, &str, ComponentExternalKind, u32)>
Gets an iterator over the component’s exports.
sourcepub fn import(
&self,
index: impl Into<ImportIndex>
) -> Option<(&str, ComponentTypeRef)>
pub fn import( &self, index: impl Into<ImportIndex> ) -> Option<(&str, ComponentTypeRef)>
Gets an import from the component for the given import index.
sourcepub fn import_by_name(
&self,
name: &str
) -> Option<(ImportIndex, ComponentTypeRef)>
pub fn import_by_name( &self, name: &str ) -> Option<(ImportIndex, ComponentTypeRef)>
Gets an import from the component for the given import name.
sourcepub fn imports(
&self
) -> impl ExactSizeIterator<Item = (ImportIndex, &str, ComponentTypeRef)>
pub fn imports( &self ) -> impl ExactSizeIterator<Item = (ImportIndex, &str, ComponentTypeRef)>
Gets an iterator over the component’s imports.
Trait Implementations§
Auto Trait Implementations§
impl<'a> RefUnwindSafe for Component<'a>
impl<'a> Send for Component<'a>
impl<'a> Sync for Component<'a>
impl<'a> Unpin for Component<'a>
impl<'a> UnwindSafe for Component<'a>
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