Struct Interface

Source
pub struct Interface {
    pub name: String,
    pub module: Option<String>,
    pub types: Arena<TypeDef>,
    pub type_lookup: HashMap<String, Id<TypeDef>>,
    pub resources: Arena<Resource>,
    pub resource_lookup: HashMap<String, Id<Resource>>,
    pub interfaces: Arena<Interface>,
    pub interface_lookup: HashMap<String, Id<Interface>>,
    pub functions: Vec<Function>,
    pub globals: Vec<Global>,
}

Fields§

§name: String§module: Option<String>

The module name to use for bindings generation.

If None, then the interface name will be used.

If Some, then this value is used to format an export name of <module>#<name> for exports or an import module name of <module> for imports.

§types: Arena<TypeDef>§type_lookup: HashMap<String, Id<TypeDef>>§resources: Arena<Resource>§resource_lookup: HashMap<String, Id<Resource>>§interfaces: Arena<Interface>§interface_lookup: HashMap<String, Id<Interface>>§functions: Vec<Function>§globals: Vec<Global>

Implementations§

Source§

impl Interface

Source

pub fn wasm_signature( &self, variant: AbiVariant, func: &Function, ) -> WasmSignature

Get the WebAssembly type signature for this interface function

The first entry returned is the list of parameters and the second entry is the list of results for the wasm function signature.

Source

pub fn call( &self, variant: AbiVariant, lift_lower: LiftLower, func: &Function, bindgen: &mut impl Bindgen, )

Generates an abstract sequence of instructions which represents this function being adapted as an imported function.

The instructions here, when executed, will emulate a language with interface types calling the concrete wasm implementation. The parameters for the returned instruction sequence are the language’s own interface-types parameters. One instruction in the instruction stream will be a Call which represents calling the actual raw wasm function signature.

This function is useful, for example, if you’re building a language generator for WASI bindings. This will document how to translate language-specific values into the wasm types to call a WASI function, and it will also automatically convert the results of the WASI function back to a language-specific value.

Source§

impl Interface

Source

pub fn parse(name: &str, input: &str) -> Result<Interface, Error>

Source

pub fn parse_file(path: impl AsRef<Path>) -> Result<Interface, Error>

Source

pub fn parse_with( filename: impl AsRef<Path>, contents: &str, load: impl FnMut(&str) -> Result<(PathBuf, String), Error>, ) -> Result<Interface, Error>

Source

pub fn topological_types(&self) -> Vec<Id<TypeDef>>

Source

pub fn all_bits_valid(&self, ty: &Type) -> bool

Source

pub fn get_variant(&self, ty: &Type) -> Option<&Variant>

Trait Implementations§

Source§

impl Debug for Interface

Source§

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

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

impl Default for Interface

Source§

fn default() -> Interface

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.