Struct GenerationSettings

Source
pub struct GenerationSettings { /* private fields */ }
Available on crate feature 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

Source

pub fn enable_all() -> GenerationSettings

Constructs GenerationSettings and enables all options at once.

Source

pub fn serialization(self, enabled: bool) -> GenerationSettings

Enabling or disabling of serialization code generation.

Source

pub fn deserialization(self, enabled: bool) -> GenerationSettings

Enabling or disabling of deserialization code generation.

Source

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.

Source

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.

Source

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.

Source

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)

Trait Implementations§

Source§

impl Debug for GenerationSettings

Source§

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

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

impl Default for GenerationSettings

Source§

fn default() -> GenerationSettings

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

Auto Trait Implementations§

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 = 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.