pub struct Renderer<'types> { /* private fields */ }Expand description
The Renderer is the central orchestrator for Rust code generation from
resolved schema types.
It allows the user to define a rendering pipeline using modular RenderSteps.
Each step contributes part of the code output - such as type definitions,
trait impls, constants, or serialization logic.
The Renderer holds configuration, shared metadata, and controls the execution
of rendering steps over the input DataTypes.
You can chain configuration methods to adjust derive traits, dynamic trait
injection, and serialization support, and then call finish
to produce a Module ready for rendering as Rust source.
Implementations§
Source§impl<'types> Renderer<'types>
impl<'types> Renderer<'types>
Sourcepub fn new(types: &'types DataTypes<'types>) -> Self
pub fn new(types: &'types DataTypes<'types>) -> Self
Create a new Renderer instance from the passed types.
Sourcepub fn with_step<X>(self, step: X) -> Selfwhere
X: RenderStep + 'types,
pub fn with_step<X>(self, step: X) -> Selfwhere
X: RenderStep + 'types,
Add a RenderStep to the renderer.
Sourcepub fn with_step_boxed(self, step: Box<dyn RenderStep + 'types>) -> Self
pub fn with_step_boxed(self, step: Box<dyn RenderStep + 'types>) -> Self
Add an already boxed RenderStep to the renderer.
Sourcepub fn with_default_steps(self) -> Self
pub fn with_default_steps(self) -> Self
Add the default renderers to the generator.
Sourcepub fn clear_steps(self) -> Self
pub fn clear_steps(self) -> Self
Remove all Renderers from the generator.
Sourcepub fn flags(self, value: RendererFlags) -> Self
pub fn flags(self, value: RendererFlags) -> Self
Set the RendererFlags flags the renderer should use for rendering the code.
Sourcepub fn derive<I>(self, value: I) -> Self
pub fn derive<I>(self, value: I) -> Self
Set the traits the generated types should derive from.
Default is Debug.
If you want to set the derive for a single value, please have a look to
DataType::derive.
§Examples
let renderer = Renderer::new(types)
.derive(["Debug", "Clone", "Eq", "PartialEq", "Ord", "PartialOrd"]);Sourcepub fn dyn_type_traits<I>(self, value: I) -> Result<Self, Error>
pub fn dyn_type_traits<I>(self, value: I) -> Result<Self, Error>
Set the traits that should be implemented by dynamic types.
The passed values must be valid type paths.
§Errors
Will raise a InvalidIdentifier error
if the passed strings does not represent a valid identifier.
§Examples
let generator = Generator::new(types)
.dyn_type_traits(["::core::fmt::Debug", "::core::any::Any"]);Sourcepub fn alloc_crate<S: Display>(self, value: S) -> Self
pub fn alloc_crate<S: Display>(self, value: S) -> Self
Set the name of the alloc create that the generator should use for
generating the code.
This is useful if the alloc create can not be resolved by the default
name in your environment. You can just set a name that suites your needs.
By default std is used as alloc crate.
Sourcepub fn xsd_parser_types<S: Display>(self, value: S) -> Self
pub fn xsd_parser_types<S: Display>(self, value: S) -> Self
Set the name of the xsd-parser-types create that the generator should use for
generating the code.
This is useful if the xsd-parser-types create can not be resolved by the default
name in your environment. You can just set a name that suites your needs.