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 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 content_mode(self, value: ContentMode) -> Self
pub fn content_mode(self, value: ContentMode) -> Self
Set the ContentMode
value 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 generate_flags(self, value: GenerateFlags) -> Self
pub fn generate_flags(self, value: GenerateFlags) -> Self
Set the GenerateFlags
flags the generator should use for generating the code.
Sourcepub fn with_generate_flags(self, value: GenerateFlags) -> Self
pub fn with_generate_flags(self, value: GenerateFlags) -> Self
Add the passed GenerateFlags
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<Self, Error>
pub fn generate_type(self, ident: Ident) -> Result<Self, Error>
Sourcepub fn generate_all_types(self) -> Result<Self, Error>
pub fn generate_all_types(self) -> Result<Self, Error>
Sourcepub fn finish(self) -> TokenStream
pub fn finish(self) -> TokenStream
Finish the code generation.
THis will return the generated code as TokenStream
.