pub struct GenerationSettings { /* private fields */ }
generating
only.Expand description
Settings for bindings generation.
This enables the possibility to enable or disable serialization, deserialization, runtime type checks or type script types. Less code will be generated if an option is off.
By default, only deserialization is enabled. Serialization can be enabled by using GenerationSettings::serialization()
.
Deserialization can be disabled with GenerationSettings::deserialization()
.
To enable all at once use GenerationSettings::enable_all()
.
Implementations§
Source§impl GenerationSettings
impl GenerationSettings
Sourcepub fn enable_all() -> GenerationSettings
pub fn enable_all() -> GenerationSettings
Constructs GenerationSettings
and enables all options at once.
Sourcepub fn serialization(self, enabled: bool) -> GenerationSettings
pub fn serialization(self, enabled: bool) -> GenerationSettings
Enabling or disabling of serialization code generation.
Sourcepub fn deserialization(self, enabled: bool) -> GenerationSettings
pub fn deserialization(self, enabled: bool) -> GenerationSettings
Enabling or disabling of deserialization code generation.
Sourcepub fn type_script_types(self, enabled: bool) -> GenerationSettings
pub fn type_script_types(self, enabled: bool) -> GenerationSettings
Enabling or disabling of typescript types code generation.
When enabling this, runtime type checks could be disabled with [‘GenerationSettings::runtime_type_checks()’] because the static type checks should enforce correct types. Additionally serialization should be faster without runtime type checks.
Sourcepub fn runtime_type_checks(self, enabled: bool) -> GenerationSettings
pub fn runtime_type_checks(self, enabled: bool) -> GenerationSettings
Enabling or disabling of runtime type checks code generation.
Disabling this should lead to a speed increase at serialization.
Sourcepub fn module_structure(self, enabled: bool) -> GenerationSettings
pub fn module_structure(self, enabled: bool) -> GenerationSettings
Enabling or disabling of module structure code generation.
Enabling this will generate the types in typescript in the same module structure as in rust. Root level types will be in the root of the generated package. Types nested in modules will be in namespaces (e.g. <mod_name>.<type_name>). This avoids name clashes.
Disabling this will generate all types in the root module.
Sourcepub fn esm_module(self, enabled: bool) -> GenerationSettings
pub fn esm_module(self, enabled: bool) -> GenerationSettings
Enabling or disabling ESM (as opposed to cjs) output
Enabling will change the way the serialize
and desrialize
functions are exported to bring them in line with ESM standards/importers.
The package.json file also gets "type": "module"
added,
so package managers/bundlers importing it know it’s ESM.
Disabling this will use the default module.exports
-style export (cjs)