Struct Interface

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

Fields§

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

Implementations§

Source§

impl Interface

Source

pub fn validate_abi(&self, func: &Function) -> Result<(), String>

Validates the parameters/results of a function are representable in its ABI.

Returns an error string if they’re not representable or returns Ok if they’re indeed representable.

Source

pub fn wasm_signature(&self, dir: Direction, 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 flags_repr(&self, record: &Record) -> Option<Int>

Source

pub fn call( &self, dir: Direction, 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>

Source

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

Source

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

Source

pub fn topological_types(&self) -> Vec<TypeId>

Source

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

Source

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

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