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 RenderStep
s.
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_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 Renderer
s 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 xsd_parser_crate<S: Display>(self, value: S) -> Self
pub fn xsd_parser_crate<S: Display>(self, value: S) -> Self
Set the name of the xsd-parser
create that the generator should use for
generating the code.