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: impl Into<String>, path: impl AsRef<Path>) -> Result<Self>
pub fn from_file(name: impl Into<String>, 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, &str, ComponentExternalKind, u32)>
pub fn export(
&self,
index: impl Into<ExportIndex>
) -> Option<(&str, &str, ComponentExternalKind, u32)>
Gets an export from the component for the given export index.
sourcepub fn export_by_name(
&self,
name: &str
) -> Option<(ExportIndex, &str, ComponentExternalKind, u32)>
pub fn export_by_name(
&self,
name: &str
) -> Option<(ExportIndex, &str, ComponentExternalKind, u32)>
Gets an export from the component for the given export name.
sourcepub fn exports(
&self
) -> impl ExactSizeIterator<Item = (ExportIndex, &str, &str, ComponentExternalKind, u32)>
pub fn exports(
&self
) -> impl ExactSizeIterator<Item = (ExportIndex, &str, &str, ComponentExternalKind, u32)>
Gets an iterator over the component’s exports.
sourcepub fn import(
&self,
index: impl Into<ImportIndex>
) -> Option<(&str, &str, ComponentTypeRef)>
pub fn import(
&self,
index: impl Into<ImportIndex>
) -> Option<(&str, &str, ComponentTypeRef)>
Gets an import from the component for the given import index.
sourcepub fn import_by_name(
&self,
name: &str
) -> Option<(ImportIndex, &str, ComponentTypeRef)>
pub fn import_by_name(
&self,
name: &str
) -> Option<(ImportIndex, &str, ComponentTypeRef)>
Gets an import from the component for the given import name.
sourcepub fn imports(
&self
) -> impl ExactSizeIterator<Item = (ImportIndex, &str, &str, ComponentTypeRef)>
pub fn imports(
&self
) -> impl ExactSizeIterator<Item = (ImportIndex, &str, &str, ComponentTypeRef)>
Gets an iterator over the component’s imports.