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.