Struct scale_typegen::typegen::settings::TypeGeneratorSettings
source · pub struct TypeGeneratorSettings {
pub types_mod_ident: Ident,
pub should_gen_docs: bool,
pub derives: DerivesRegistry,
pub substitutes: TypeSubstitutes,
pub decoded_bits_type_path: Option<Path>,
pub compact_as_type_path: Option<Path>,
pub compact_type_path: Option<Path>,
pub insert_codec_attributes: bool,
pub alloc_crate_path: AllocCratePath,
}
Expand description
A struct containing all the settings for generating rust types from a type registry.
Fields§
§types_mod_ident: Ident
The name of the module which will contain the generated types.
should_gen_docs: bool
If false, no docs are generated for the types.
derives: DerivesRegistry
Derive traits on generated types.
substitutes: TypeSubstitutes
User defined overrides for generated types.
decoded_bits_type_path: Option<Path>
Two generic parameters are expected on this type:
- Store (e.g.
u8
/u16
/u32
/u64
) - Order (e.g. LSB, MSB)
subxt provides a subxt::utils::DecodedBits
that can be used here.
compact_as_type_path: Option<Path>
TypePath to the CompactAs trait/derive macro.
E.g. subxt::ext::codec::CompactAs
compact_type_path: Option<Path>
TypePath to the Compactsubxt::ext::codec::Compact
insert_codec_attributes: bool
If false, no codec attributes like codec(index=0)
and codec(compact)
are inserted.
This is a useful option if we do not want to derive Decode and Encode on our types.
alloc_crate_path: AllocCratePath
Configure a custom type path for the alloc
crate, which is the base for generating type paths like
alloc::string::String
, alloc::vec::Vec
and alloc::boxed::Box
. The default is AllocCratePath::Std
which
uses the types from the std
library instead.
Implementations§
source§impl TypeGeneratorSettings
impl TypeGeneratorSettings
sourcepub fn type_mod_name(self, type_mod_name: &str) -> Self
pub fn type_mod_name(self, type_mod_name: &str) -> Self
Sets the type_mod_name
field.
sourcepub fn substitute(self, from: Path, to: Path) -> Self
pub fn substitute(self, from: Path, to: Path) -> Self
Adds a rule, that a type with path from
should be replaced with the path to
.
sourcepub fn compact_as_type_path(self, path: Path) -> Self
pub fn compact_as_type_path(self, path: Path) -> Self
Sets the compact_as_type_path
field.
sourcepub fn compact_type_path(self, path: Path) -> Self
pub fn compact_type_path(self, path: Path) -> Self
Sets the compact_type_path
field.
sourcepub fn decoded_bits_type_path(self, path: Path) -> Self
pub fn decoded_bits_type_path(self, path: Path) -> Self
Sets the decoded_bits_type_path
field.
sourcepub fn should_gen_docs(self, should_gen_docs: bool) -> Self
pub fn should_gen_docs(self, should_gen_docs: bool) -> Self
Sets the should_gen_docs
field.
sourcepub fn insert_codec_attributes(self) -> Self
pub fn insert_codec_attributes(self) -> Self
Sets the insert_codec_attributes
field.
sourcepub fn add_derives_for_all(
self,
derive_paths: impl IntoIterator<Item = Path>
) -> Self
pub fn add_derives_for_all( self, derive_paths: impl IntoIterator<Item = Path> ) -> Self
Adds some derives for all types.
Trait Implementations§
source§impl Clone for TypeGeneratorSettings
impl Clone for TypeGeneratorSettings
source§fn clone(&self) -> TypeGeneratorSettings
fn clone(&self) -> TypeGeneratorSettings
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TypeGeneratorSettings
impl Debug for TypeGeneratorSettings
Auto Trait Implementations§
impl Freeze for TypeGeneratorSettings
impl RefUnwindSafe for TypeGeneratorSettings
impl !Send for TypeGeneratorSettings
impl !Sync for TypeGeneratorSettings
impl Unpin for TypeGeneratorSettings
impl UnwindSafe for TypeGeneratorSettings
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> FmtForward for T
impl<T> FmtForward for T
source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.