wit_bindgen_rust

Struct Opts

Source
pub struct Opts {
Show 19 fields pub format: bool, pub std_feature: bool, pub raw_strings: bool, pub skip: Vec<String>, pub stubs: bool, pub export_prefix: Option<String>, pub ownership: Ownership, pub runtime_path: Option<String>, pub bitflags_path: Option<String>, pub additional_derive_attributes: Vec<String>, pub with: Vec<(String, WithOption)>, pub generate_all: bool, pub type_section_suffix: Option<String>, pub disable_run_ctors_once_workaround: bool, pub default_bindings_module: Option<String>, pub export_macro_name: Option<String>, pub pub_export_macro: bool, pub generate_unused_types: bool, pub disable_custom_section_link_helpers: bool,
}

Fields§

§format: bool

Whether or not a formatter is executed to format generated code.

§std_feature: bool

If true, code generation should qualify any features that depend on std with cfg(feature = "std").

§raw_strings: bool

If true, code generation should pass borrowed string arguments as &[u8] instead of &str. Strings are still required to be valid UTF-8, but this avoids the need for Rust code to do its own UTF-8 validation if it doesn’t already have a &str.

§skip: Vec<String>

Names of functions to skip generating bindings for.

§stubs: bool

If true, generate stub implementations for any exported functions, interfaces, and/or resources.

§export_prefix: Option<String>

Optionally prefix any export names with the specified value.

This is useful to avoid name conflicts when testing.

§ownership: Ownership

Whether to generate owning or borrowing type definitions.

Valid values include:

  • owning: Generated types will be composed entirely of owning fields, regardless of whether they are used as parameters to imports or not.

  • borrowing: Generated types used as parameters to imports will be “deeply borrowing”, i.e. contain references rather than owned values when applicable.

  • borrowing-duplicate-if-necessary: As above, but generating distinct types for borrowing and owning, if necessary.

§runtime_path: Option<String>

The optional path to the wit-bindgen runtime module to use.

This defaults to wit_bindgen::rt.

§bitflags_path: Option<String>

The optional path to the bitflags crate to use.

This defaults to wit_bindgen::bitflags.

§additional_derive_attributes: Vec<String>

Additional derive attributes to add to generated types. If using in a CLI, this flag can be specified multiple times to add multiple attributes.

These derive attributes will be added to any generated structs or enums

§with: Vec<(String, WithOption)>

Remapping of interface names to rust module names.

Argument must be of the form k=v and this option can be passed multiple times or one option can be comma separated, for example k1=v1,k2=v2.

§generate_all: bool

Indicates that all interfaces not specified in with should be generated.

§type_section_suffix: Option<String>

Add the specified suffix to the name of the custome section containing the component type.

§disable_run_ctors_once_workaround: bool

Disable a workaround used to prevent libc ctors/dtors from being invoked too much.

§default_bindings_module: Option<String>

Changes the default module used in the generated export! macro to something other than self.

§export_macro_name: Option<String>

Alternative name to use for the export! macro if one is generated.

§pub_export_macro: bool

Ensures that the export! macro will be defined as pub so it is a candidate for being exported outside of the crate.

§generate_unused_types: bool

Whether to generate unused structures, not generated by default (false)

§disable_custom_section_link_helpers: bool

Whether or not to generate helper function/constants to help link custom sections into the final output.

Disabling this can shave a few bytes off a binary but makes library-based usage of generate! prone to breakage.

Implementations§

Source§

impl Opts

Source

pub fn build(self) -> Box<dyn WorldGenerator>

Trait Implementations§

Source§

impl Clone for Opts

Source§

fn clone(&self) -> Opts

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 Debug for Opts

Source§

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

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

impl Default for Opts

Source§

fn default() -> Opts

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

Auto Trait Implementations§

§

impl Freeze for Opts

§

impl RefUnwindSafe for Opts

§

impl Send for Opts

§

impl Sync for Opts

§

impl Unpin for Opts

§

impl UnwindSafe for Opts

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§

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,

Source§

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

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.