Struct typify_impl::TypeSpaceSettings
source · pub struct TypeSpaceSettings { /* private fields */ }
Expand description
Settings that alter type generation.
Implementations§
source§impl TypeSpaceSettings
impl TypeSpaceSettings
sourcepub fn with_type_mod<S: AsRef<str>>(&mut self, type_mod: S) -> &mut Self
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.
sourcepub fn with_derive(&mut self, derive: String) -> &mut Self
pub fn with_derive(&mut self, derive: String) -> &mut Self
Add an additional derive macro to apply to all defined types.
sourcepub fn with_struct_builder(&mut self, struct_builder: bool) -> &mut Self
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.
sourcepub fn with_replacement<TS: ToString, RS: ToString, I: Iterator<Item = TypeSpaceImpl>>(
&mut self,
type_name: TS,
replace_type: RS,
impls: I
) -> &mut Self
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.
sourcepub fn with_patch<S: ToString>(
&mut self,
type_name: S,
type_patch: &TypeSpacePatch
) -> &mut Self
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.
sourcepub fn with_conversion<S: ToString, I: Iterator<Item = TypeSpaceImpl>>(
&mut self,
schema: SchemaObject,
type_name: S,
impls: I
) -> &mut Self
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.
sourcepub fn with_unknown_crates(&mut self, policy: UnknownPolicy) -> &mut Self
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
.
sourcepub fn with_crate<S1: ToString>(
&mut self,
crate_name: S1,
version: CrateVers,
rename: Option<&String>
) -> &mut Self
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
impl Clone for TypeSpaceSettings
source§fn clone(&self) -> TypeSpaceSettings
fn clone(&self) -> TypeSpaceSettings
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more