Struct Component

Source
pub struct Component<'a> { /* private fields */ }
Expand description

Represents a component in a composition graph.

Implementations§

Source§

impl<'a> Component<'a>

Source

pub fn from_file( validator: &mut Validator, name: &str, path: impl AsRef<Path>, ) -> Result<Self>

Constructs a new component from reading the given file.

Source

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.

Source

pub fn name(&self) -> &str

Gets the name of the component.

Names must be unique within a composition graph.

Source

pub fn path(&self) -> Option<&Path>

Gets the path of the component.

Returns None if the component was not loaded from a file.

Source

pub fn bytes(&self) -> &[u8]

Gets the bytes of the component.

Source

pub fn types(&self) -> TypesRef<'_>

Gets the type information of the component.

Source

pub fn export( &self, index: impl Into<ExportIndex>, ) -> Option<(&str, ComponentExternalKind, u32)>

Gets an export from the component for the given export index.

Source

pub fn export_by_name( &self, name: &str, ) -> Option<(ExportIndex, ComponentExternalKind, u32)>

Gets an export from the component for the given export name.

Source

pub fn exports( &self, ) -> impl ExactSizeIterator<Item = (ExportIndex, &str, ComponentExternalKind, u32)>

Gets an iterator over the component’s exports.

Source

pub fn import( &self, index: impl Into<ImportIndex>, ) -> Option<(&str, ComponentTypeRef)>

Gets an import from the component for the given import index.

Source

pub fn import_by_name( &self, name: &str, ) -> Option<(ImportIndex, ComponentTypeRef)>

Gets an import from the component for the given import name.

Source

pub fn imports( &self, ) -> impl ExactSizeIterator<Item = (ImportIndex, &str, ComponentTypeRef)>

Gets an iterator over the component’s imports.

Trait Implementations§

Source§

impl Debug for Component<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.