Struct typify_impl::TypeSpaceSettings

source ·
pub struct TypeSpaceSettings { /* private fields */ }
Expand description

Settings that alter type generation.

Implementations§

source§

impl TypeSpaceSettings

source

pub fn with_type_mod<S: AsRef<str>>(&mut self, type_mod: S) -> &mut Self

Set the name of the path prefix for types defined in this TypeSpace.

source

pub fn with_derive(&mut self, derive: String) -> &mut Self

Add an additional derive macro to apply to all defined types.

source

pub fn with_struct_builder(&mut self, struct_builder: bool) -> &mut Self

For structs, include a “builder” type that can be used to construct it.

source

pub fn with_replacement<TS: ToString, RS: ToString, I: Iterator<Item = TypeSpaceImpl>>( &mut self, type_name: TS, replace_type: RS, impls: I ) -> &mut Self

Replace a referenced type with a named type. This causes the referenced type not to be generated. If the same type_name is specified multiple times, the last one is honored.

source

pub fn with_patch<S: ToString>( &mut self, type_name: S, type_patch: &TypeSpacePatch ) -> &mut Self

Modify a type with the given name. Note that specifying a type not created by the input JSON schema does not result in an error and is silently ignored. If the same type_name is specified multiple times, the last one is honored.

source

pub fn with_conversion<S: ToString, I: Iterator<Item = TypeSpaceImpl>>( &mut self, schema: SchemaObject, type_name: S, impls: I ) -> &mut Self

Replace a given schema with a named type. The given schema must precisely match the schema from the input, including fields such as description. Typical usage is to map a schema definition to a builtin type or type provided by a crate, such as 'rust_decimal::Decimal'. If the same schema is specified multiple times, the first one is honored.

source

pub fn with_unknown_crates(&mut self, policy: UnknownPolicy) -> &mut Self

Type schemas may contain an extension (x-rust-type) that indicates the corresponding Rust type within a particular crate. This function changes the disposition regarding crates not otherwise specified via Self::with_crate. The default value is false.

source

pub fn with_crate<S1: ToString>( &mut self, crate_name: S1, version: CrateVers, rename: Option<&String> ) -> &mut Self

Type schemas may contain an extension (x-rust-type) that indicates the corresponding Rust type within a particular crate. This extension indicates the crate, version compatibility, type path, and type parameters. This function modifies settings to use (rather than generate) types from the given crate and version. The version should precisely match the version of the crate that you expect as a dependency.

Trait Implementations§

source§

impl Clone for TypeSpaceSettings

source§

fn clone(&self) -> TypeSpaceSettings

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 TypeSpaceSettings

source§

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

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

impl Default for TypeSpaceSettings

source§

fn default() -> TypeSpaceSettings

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> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

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,

§

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

§

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

§

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.