Struct wit_bindgen_rust::Opts

source ·
pub struct Opts {
    pub rustfmt: bool,
    pub std_feature: bool,
    pub raw_strings: bool,
    pub skip: Vec<String>,
    pub exports: HashMap<ExportKey, 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: HashMap<String, String>,
}

Fields§

§rustfmt: bool

Whether or not rustfmt 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.

§exports: HashMap<ExportKey, String>

Names of the concrete types which implement the traits representing any functions, interfaces, and/or resources exported by the world.

Example: --exports world=MyWorld,ns:pkg/iface1=MyIface1,ns:pkg/iface1/resource1=MyResource1,

§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: HashMap<String, String>

Remapping of interface names to rust module names.

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 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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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 Twhere 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.