Struct golem_wasm_ast::component::Component

source ·
pub struct Component<Ast: AstCustomization + 'static> { /* private fields */ }
Expand description

The top level node of the Component Model AST

Implementations§

source§

impl<Ast> Component<Ast>
where Ast: AstCustomization, Ast::Expr: TryFromExprSource, Ast::Data: From<Data<Ast::Expr>>, Ast::Custom: From<Custom>,

source

pub fn from_bytes(bytes: &[u8]) -> Result<Self, String>

Parses a Component Model AST from the binary WASM byte array

source§

impl<Ast> Component<Ast>
where Ast: AstCustomization, Ast::Expr: RetainsInstructions, Ast::Data: Into<Data<Ast::Expr>>, Ast::Custom: Into<Custom>,

source

pub fn into_bytes(self) -> Result<Vec<u8>, String>

Serializes a WASM Component into a binary WASM byte array

source§

impl<Ast: AstCustomization> Component<Ast>

source

pub fn empty() -> Self

Creates an empty component

source

pub fn imports(&self) -> Vec<Mrc<ComponentImport>>

Gets all the imports defined in this component

source

pub fn exports(&self) -> Vec<Mrc<ComponentExport>>

Gets all the exports defined in this component

source

pub fn core_instances(&self) -> Vec<Mrc<Instance>>

Gets all the core instances defined in this component

source

pub fn instances(&self) -> Vec<Mrc<ComponentInstance>>

Gets all the component instances defined in this component

source

pub fn component_types(&self) -> Vec<Mrc<ComponentType>>

Gets all the component types defined in this component

source

pub fn core_types(&self) -> Vec<Mrc<CoreType>>

Gets all the core types defined in this component

source

pub fn canons(&self) -> Vec<Mrc<Canon>>

Gets all the canonical function definitions of this component

source

pub fn aliases(&self) -> Vec<Mrc<Alias>>

Gets all the aliases defined in this component

source

pub fn components(&self) -> Vec<Mrc<Component<Ast>>>

Gets all the inner components defined in this component

source

pub fn modules(&self) -> Vec<Mrc<Module<Ast>>>

Gets all the inner core modules defined in this component

source

pub fn customs(&self) -> Vec<Mrc<Ast::Custom>>

Gets all the custom sections defined in this component

source

pub fn get_core_instance( &self, core_instance_idx: CoreInstanceIdx, ) -> Option<Mrc<Instance>>

Returns the core instance referenced by the given index.

source

pub fn get_instance_wrapped( &self, instance_idx: InstanceIdx, ) -> Option<Mrc<ComponentSection<Ast>>>

Returns the component instance referenced by the given index.

source

pub fn get_instance( &self, instance_idx: InstanceIdx, ) -> Option<Mrc<ComponentInstance>>

Returns the component instance referenced by the given index.

source

pub fn get_component_type( &self, component_type_idx: ComponentTypeIdx, ) -> Option<Mrc<ComponentSection<Ast>>>

Returns the component type referenced by the given index.

It can be one of the following section types:

  • ComponentType
  • Alias
  • ComponentExport
  • ComponentImport
source

pub fn get_core_func( &self, core_func_idx: FuncIdx, ) -> Option<Mrc<ComponentSection<Ast>>>

Returns the core function referenced by the given index.

It can be one of the following section types:

  • Canon
  • Alias
source

pub fn get_component( &self, component_idx: ComponentIdx, ) -> Option<Mrc<ComponentSection<Ast>>>

Returns the component referenced by the given index.

It can be one of the following section types:

  • Component
  • Alias
  • ComponentExport
  • ComponentImport
source

pub fn get_component_func( &self, component_func_idx: ComponentFuncIdx, ) -> Option<Mrc<ComponentSection<Ast>>>

Returns the component function referenced by the given index.

It can be one of the following section types:

  • Canon
  • Alias
  • ComponentExport
  • ComponentImport
source

pub fn get_value( &self, value_idx: ValueIdx, ) -> Option<Mrc<ComponentSection<Ast>>>

Returns the value referenced by the given index.

It can be one of the following section types:

  • Alias
  • ComponentExport
  • ComponentImport
source

pub fn get_module( &self, module_idx: ModuleIdx, ) -> Option<Mrc<ComponentSection<Ast>>>

Returns the module referenced by the given index.

It can be one of the following section types:

  • Module
  • Alias
  • ComponentExport
  • ComponentImport
source

pub fn into_sections(self) -> Vec<Mrc<ComponentSection<Ast>>>

Converts this component into a sequence of component sections.

source

pub fn into_grouped( self, ) -> Vec<(ComponentSectionType, Vec<Mrc<ComponentSection<Ast>>>)>

Converts this component into a sequence of grouped component sections, exactly as it would be in the binary WASM format.

source§

impl<Ast> Component<Ast>

source

pub fn get_metadata(&self) -> Option<Metadata>

source

pub fn get_all_producers(&self) -> Vec<Producers>

Collects all the producers sections from this component and its subsections

Trait Implementations§

source§

impl<Ast: AstCustomization> Clone for Component<Ast>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Ast: AstCustomization> Debug for Component<Ast>

source§

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

Formats the value using the given formatter. Read more
source§

impl<Ast: AstCustomization> PartialEq for Component<Ast>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<Ast: AstCustomization> Section<ComponentIndexSpace, ComponentSectionType> for Component<Ast>

source§

impl<Ast> TryFrom<Component<Ast>> for Component
where Ast: AstCustomization, Ast::Expr: RetainsInstructions, Ast::Data: Into<Data<Ast::Expr>>, Ast::Custom: Into<Custom>,

§

type Error = String

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

fn try_from(value: Component<Ast>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<Ast> !Freeze for Component<Ast>

§

impl<Ast> !RefUnwindSafe for Component<Ast>

§

impl<Ast> !Send for Component<Ast>

§

impl<Ast> !Sync for Component<Ast>

§

impl<Ast> Unpin for Component<Ast>

§

impl<Ast> !UnwindSafe for Component<Ast>

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> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.