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(
validator: &mut Validator,
name: &str,
path: impl AsRef<Path>,
) -> Result<Self>
pub fn from_file( validator: &mut Validator, name: &str, path: impl AsRef<Path>, ) -> Result<Self>
Constructs a new component from reading the given file.
Sourcepub fn from_bytes(
validator: &mut Validator,
name: impl Into<String>,
bytes: impl Into<Cow<'a, [u8]>>,
) -> Result<Self>
pub fn from_bytes( validator: &mut Validator, 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> Freeze for Component<'a>
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