Skip to main content

FunctionBindgen

Struct FunctionBindgen 

Source
#[non_exhaustive]
pub struct FunctionBindgen<'a> {
Show 36 fields pub skip_fn_call_task_management: bool, pub resource_map: &'a ResourceMap, pub guest_resource_class_names: Option<&'a BTreeMap<TypeId, String>>, pub clear_resource_borrows: bool, pub intrinsics: &'a mut BTreeSet<Intrinsic>, pub valid_lifting_optimization: bool, pub flags_as_bigint: bool, pub enum_values_screaming_snake_case: bool, pub sizes: &'a SizeAlign, pub err: ErrHandling, pub tmp: usize, pub src: Source, pub block_storage: Vec<Source>, pub blocks: Vec<(String, Vec<String>)>, pub params: Vec<String>, pub memory: Option<&'a String>, pub realloc: Option<&'a String>, pub dealloc: Option<&'a String>, pub post_return: Option<&'a String>, pub tracing_prefix: &'a String, pub tracing_enabled: bool, pub no_component_error_wrapping: bool, pub encoding: StringEncoding, pub callee: &'a str, pub callee_resource_dynamic: bool, pub resolve: &'a Resolve, pub requires_async_porcelain: bool, pub is_async: bool, pub canonical_abi_async: bool, pub func_type_async: bool, pub return_result_type_idx: Option<u32>, pub wrap_async_future_result: bool, pub result_ty: Option<&'a Type>, pub iface_name: Option<&'a str>, pub asmjs: bool, pub component_state: Option<FunctionBindgenComponentState>, /* private fields */
}

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§skip_fn_call_task_management: bool

Skip task management for generated function calls. Defaults to false.

This is normally used by embedders when they want to run generated bindings inside a wasm guest and let the native embedding manage execution and canonical abi call lifetimes instead of the host task runtime.

§resource_map: &'a ResourceMap

Mapping of resources for types that have corresponding definitions locally

§guest_resource_class_names: Option<&'a BTreeMap<TypeId, String>>

Allocated JS class names for guest-defined resources, keyed by their dealiased WIT type. Embedders can supply these when distinct interfaces declare resources with the same name. Omitted entries use the WIT name.

§clear_resource_borrows: bool

Whether current resource borrows need to be deactivated

§intrinsics: &'a mut BTreeSet<Intrinsic>

Set of intrinsics

§valid_lifting_optimization: bool

Whether to perform valid lifting optimization

§flags_as_bigint: bool

Whether WIT flags are represented as bigint values.

§enum_values_screaming_snake_case: bool

Whether WIT enum values use SCREAMING_SNAKE_CASE strings.

§sizes: &'a SizeAlign

Sizes and alignments for sub elements

§err: ErrHandling

Method of error handling

§tmp: usize

Temporary values

§src: Source

Source code of the function

§block_storage: Vec<Source>

Block storage

§blocks: Vec<(String, Vec<String>)>

Blocks of the function

§params: Vec<String>

Parameters of the function

§memory: Option<&'a String>

Memory variable

§realloc: Option<&'a String>

Realloc function name

§dealloc: Option<&'a String>

Synchronous deallocator for owned canonical ABI buffers.

§post_return: Option<&'a String>

Post return function name

§tracing_prefix: &'a String

Prefix to use when printing tracing information

§tracing_enabled: bool

Whether tracing is enabled

§no_component_error_wrapping: bool

Whether top-level result errors should be thrown as their raw lifted payload.

§encoding: StringEncoding

Method if string encoding

§callee: &'a str

Callee of the function

§callee_resource_dynamic: bool

Whether the callee is dynamic (i.e. has multiple operands)

§resolve: &'a Resolve

The [wit_bindgen::Resolve] containing extracted WIT information

§requires_async_porcelain: bool

Whether the function requires async porcelain

In the case of an import this likely implies the use of JSPI and in the case of an export this is simply code generation metadata.

§is_async: bool

Whether the function is guest async lifted (i.e. WASI P3)

§canonical_abi_async: bool

Whether the canonical ABI call itself is async.

This can differ from is_async when an async component function is canonically lifted from a synchronous core function.

§func_type_async: bool

Whether the component-level function type is async (independently of how it was lifted or lowered)

§return_result_type_idx: Option<u32>

The interned index of the result tuple type of an exported function, which task.return must match

§wrap_async_future_result: bool

Whether an async export returning a future needs a non-async outer function to preserve the future as a distinct awaitable layer.

§result_ty: Option<&'a Type>

Component result type, used to lift callbackless async core returns.

§iface_name: Option<&'a str>

Interface name

§asmjs: bool

Whether the callee was transpiled from Wasm to JS (asm.js) and thus needs shimming for i64

§component_state: Option<FunctionBindgenComponentState>

Component state generated from processing a component.

This information is normally accessible via producing/having access to a wasmtime_environ::component::Component), and is required for some bindgen instructions.

If you are performing bindgen aganist a dummy module, you may omit this field, but if processing has been performed on the component, and this state is available at time of generation for this function, provide this information (normally found in [CanonicalOptions]s)

Implementations§

Source§

impl<'a> FunctionBindgen<'a>

Source

pub fn builder() -> FunctionBindgenBuilder<'a>

Create an instance of FunctionBindgen using the builder syntax

Trait Implementations§

Source§

impl Bindgen for FunctionBindgen<'_>

Source§

fn sizes(&self) -> &SizeAlign

Get the sizes and alignment for a given structure

Source§

fn push_block(&mut self)

Push a new block of code

Source§

fn finish_block(&mut self, operands: &mut Vec<String>)

Finish a block of code

Source§

fn return_pointer( &mut self, _size: ArchitectureSize, _align: Alignment, ) -> String

Output the return pointer

Source§

fn is_list_canonical(&self, resolve: &Resolve, elem_ty: &Type) -> bool

Check whether a list of the given element type can be represented as a builtni JS type

§Arguments
  • resolve - the Resolve that might be used to resolve nested types (i.e. [Type::TypeId])
  • elem_ty - the Type of the element stored in the list
Source§

type Operand = String

The intermediate type for fragments of code for this type. Read more
Source§

fn emit( &mut self, resolve: &Resolve, inst: &Instruction<'_>, operands: &mut Vec<String>, results: &mut Vec<String>, )

Emit code to implement the given instruction. Read more

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for FunctionBindgen<'a>

§

impl<'a> Freeze for FunctionBindgen<'a>

§

impl<'a> RefUnwindSafe for FunctionBindgen<'a>

§

impl<'a> Send for FunctionBindgen<'a>

§

impl<'a> Sync for FunctionBindgen<'a>

§

impl<'a> Unpin for FunctionBindgen<'a>

§

impl<'a> UnsafeUnpin for FunctionBindgen<'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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.