Struct Generator

Source
pub struct Generator<'types> { /* private fields */ }
Expand description

Type that is used to generate rust code from a Types object.

Implementations§

Source§

impl<'types> Generator<'types>

Source

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

Create a new code generator from the passed types.

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 derive<I>(self, value: I) -> Self
where I: IntoIterator, I::Item: Display,

Set the traits the generated types should derive from.

Default is Debug and Clone.

§Examples
let generator = Generator::new(types)
    .derive(["Debug", "Clone", "Eq", "PartialEq", "Ord", "PartialOrd"]);
Source

pub fn dyn_type_traits<I>(self, value: I) -> Self
where I: IntoIterator, I::Item: Into<String>,

Set the traits that should be implemented by dynamic types.

The passed values must be valid type paths.

§Examples
let generator = Generator::new(types)
    .dyn_type_traits(["core::fmt::Debug", "core::any::Any"]);
Source

pub fn box_flags(self, value: BoxFlags) -> Self

Set the BoxFlags flags the generator should use for generating the code.

Source

pub fn typedef_mode(self, value: TypedefMode) -> Self

Set the TypedefMode value the generator should use for generating the code.

Source

pub fn serde_support(self, value: SerdeSupport) -> Self

Set the SerdeSupport value the generator should use for generating the code.

Source

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

Set the GeneratorFlags flags the generator should use for generating the code.

Source

pub fn with_flags(self, value: GeneratorFlags) -> Self

Add the passed GeneratorFlags flags the generator should use for generating the code.

Source

pub fn with_type_postfix<S: Into<String>>( self, type_: IdentType, postfix: S, ) -> Self

Set the postfixes the generator should use for the different types.

Default is "Type" for the IdentType::Type type and "" for the other types.

Source

pub fn with_type(self, ident: Ident) -> Result<Self, Error>

Add a custom implemented type to the generator.

This will add a custom implemented type to the generator. These types are usually implemented and provided by the user of the generated code. The generator will just reference to the type definition and will not generate any code related to this type.

§Errors

Returns an error if the namespace of the passed identifier is unknown.

§Examples
let generator = Generator::new(types)
    .with_type(Ident::type_("UserDefinedType"));
Source

pub fn generate_type( self, ident: Ident, ) -> Result<GeneratorFixed<'types>, Error>

Will fix the generator by call into_fixed and then generate_type.

Source

pub fn generate_all_types(self) -> Result<GeneratorFixed<'types>, Error>

Will fix the generator by call into_fixed and then generate_all_types.

§Errors

Will just forward the errors from generate_all_types.

Source

pub fn into_fixed(self) -> GeneratorFixed<'types>

Will convert the generator into a GeneratorFixed.

Trait Implementations§

Source§

impl<'types> Debug for Generator<'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 Generator<'types>

§

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

§

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

§

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

§

impl<'types> Unpin for Generator<'types>

§

impl<'types> !UnwindSafe for Generator<'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