Struct Renderer

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

Source

pub fn new(types: &'types DataTypes<'types>) -> Self

Create a new Renderer instance from the passed types.

Source

pub fn with_step<X>(self, step: X) -> Self
where X: RenderStep + 'types,

Add a RenderStep to the renderer.

Source

pub fn with_default_steps(self) -> Self

Add the default renderers to the generator.

Source

pub fn clear_steps(self) -> Self

Remove all Renderers from the generator.

Source

pub fn flags(self, value: RendererFlags) -> Self

Set the RendererFlags flags the renderer should use for rendering the code.

Source

pub fn derive<I>(self, value: I) -> Self
where I: IntoIterator, I::Item: Display,

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"]);
Source

pub fn dyn_type_traits<I>(self, value: I) -> Result<Self, Error>
where I: IntoIterator, I::Item: AsRef<str>,

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"]);
Source

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.

Source

pub fn finish(self) -> Module

Finish the rendering process and return the resulting Module.

Trait Implementations§

Source§

impl<'types> Debug for Renderer<'types>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'types> Freeze for Renderer<'types>

§

impl<'types> !RefUnwindSafe for Renderer<'types>

§

impl<'types> !Send for Renderer<'types>

§

impl<'types> !Sync for Renderer<'types>

§

impl<'types> Unpin for Renderer<'types>

§

impl<'types> !UnwindSafe for Renderer<'types>

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<X> AsAny for X
where X: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Get a reference to the current object as Any.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Get a mutable reference to the current object as Any.
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T