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>
impl<'types> Generator<'types>
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.
Sourcepub fn dyn_type_traits<I>(self, value: I) -> Self
pub fn dyn_type_traits<I>(self, value: I) -> Self
Sourcepub fn box_flags(self, value: BoxFlags) -> Self
pub fn box_flags(self, value: BoxFlags) -> Self
Set the BoxFlags flags the generator should use for generating the code.
Sourcepub fn typedef_mode(self, value: TypedefMode) -> Self
pub fn typedef_mode(self, value: TypedefMode) -> Self
Set the TypedefMode value the generator should use for generating the code.
Sourcepub fn serde_support(self, value: SerdeSupport) -> Self
pub fn serde_support(self, value: SerdeSupport) -> Self
Set the SerdeSupport value the generator should use for generating the code.
Sourcepub fn flags(self, value: GeneratorFlags) -> Self
pub fn flags(self, value: GeneratorFlags) -> Self
Set the GeneratorFlags flags the generator should use for generating the code.
Sourcepub fn with_flags(self, value: GeneratorFlags) -> Self
pub fn with_flags(self, value: GeneratorFlags) -> Self
Add the passed GeneratorFlags flags the generator should use for generating the code.
Sourcepub fn with_type_postfix<S: Into<String>>(
self,
type_: IdentType,
postfix: S,
) -> Self
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.
Sourcepub fn with_type(self, ident: Ident) -> Result<Self, Error>
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"));Sourcepub fn generate_type(
self,
ident: Ident,
) -> Result<GeneratorFixed<'types>, Error>
pub fn generate_type( self, ident: Ident, ) -> Result<GeneratorFixed<'types>, Error>
Will fix the generator by call into_fixed and then
generate_type.
Sourcepub fn generate_all_types(self) -> Result<GeneratorFixed<'types>, Error>
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.
Sourcepub fn into_fixed(self) -> GeneratorFixed<'types>
pub fn into_fixed(self) -> GeneratorFixed<'types>
Will convert the generator into a GeneratorFixed.