pub trait Naming: Debug {
Show 14 methods
// Required methods
fn clone_boxed(&self) -> Box<dyn Naming>;
fn builder(&self) -> Box<dyn NameBuilder>;
// Provided methods
fn unify(&self, s: &str) -> String { ... }
fn format_type_name(&self, s: &str) -> String { ... }
fn format_field_name(&self, s: &str) -> String { ... }
fn format_variant_name(&self, s: &str) -> String { ... }
fn format_module_name(&self, s: &str) -> String { ... }
fn format_type_ident(
&self,
name: &Name,
display_name: Option<&str>,
) -> Ident2 { ... }
fn format_field_ident(
&self,
name: &Name,
display_name: Option<&str>,
) -> Ident2 { ... }
fn format_variant_ident(
&self,
name: &Name,
display_name: Option<&str>,
) -> Ident2 { ... }
fn format_module_ident(&self, name: &Name) -> Ident2 { ... }
fn format_module(
&self,
types: &MetaTypes,
ns: Option<NamespaceId>,
) -> Option<Ident2> { ... }
fn make_type_name(
&self,
postfixes: &[String],
ty: &MetaType,
ident: &Ident,
) -> Name { ... }
fn make_unknown_variant(&self, id: usize) -> Ident2 { ... }
}Expand description
This trait defined how names are generated and formatted in xsd-parser.
Use the Interpreter::with_naming method
to use a customized implementation for this trait.
Required Methods§
Sourcefn clone_boxed(&self) -> Box<dyn Naming>
fn clone_boxed(&self) -> Box<dyn Naming>
Clone this object into a new Box.
Sourcefn builder(&self) -> Box<dyn NameBuilder>
fn builder(&self) -> Box<dyn NameBuilder>
Create a new name builder instance.
Provided Methods§
Sourcefn unify(&self, s: &str) -> String
fn unify(&self, s: &str) -> String
Unify the given string.
Before actual name generation or formatting it is sometimes useful to have a pre-formatting for names, to have a unified schema for the names in general.
The default implementation uses pascal case to unify all different kind of names.
Sourcefn format_type_name(&self, s: &str) -> String
fn format_type_name(&self, s: &str) -> String
Format the passed string s as type name.
The default implementation uses pascal case here.
Sourcefn format_field_name(&self, s: &str) -> String
fn format_field_name(&self, s: &str) -> String
Format the passed string s as field name.
The default implementation uses snake case here.
Sourcefn format_variant_name(&self, s: &str) -> String
fn format_variant_name(&self, s: &str) -> String
Format the passed string s as variant name.
The default implementation uses format_type_name here.
Sourcefn format_module_name(&self, s: &str) -> String
fn format_module_name(&self, s: &str) -> String
Format the passed string s as module name.
The default implementation uses format_field_name here.
Sourcefn format_type_ident(&self, name: &Name, display_name: Option<&str>) -> Ident2
fn format_type_ident(&self, name: &Name, display_name: Option<&str>) -> Ident2
Create a suitable identifier for the passed type name name respecting
user defined names stored in display_name.
The default implementation uses the display_name or name as fallback
and formats it using format_type_name.
Sourcefn format_field_ident(&self, name: &Name, display_name: Option<&str>) -> Ident2
fn format_field_ident(&self, name: &Name, display_name: Option<&str>) -> Ident2
Create a suitable identifier for the passed field name name respecting
user defined names stored in display_name.
The default implementation uses the display_name or name as fallback
and formats it using format_field_name.
Sourcefn format_variant_ident(
&self,
name: &Name,
display_name: Option<&str>,
) -> Ident2
fn format_variant_ident( &self, name: &Name, display_name: Option<&str>, ) -> Ident2
Create a suitable identifier for the passed variant name name respecting
user defined names stored in display_name.
The default implementation uses format_type_ident here.
Sourcefn format_module_ident(&self, name: &Name) -> Ident2
fn format_module_ident(&self, name: &Name) -> Ident2
Create a suitable identifier for the passed module name name.
The default implementation uses format_module_ident
with display_name set to None here.
Sourcefn format_module(
&self,
types: &MetaTypes,
ns: Option<NamespaceId>,
) -> Option<Ident2>
fn format_module( &self, types: &MetaTypes, ns: Option<NamespaceId>, ) -> Option<Ident2>
Generate a identifier for the module identified by ns.
Sourcefn make_type_name(
&self,
postfixes: &[String],
ty: &MetaType,
ident: &Ident,
) -> Name
fn make_type_name( &self, postfixes: &[String], ty: &MetaType, ident: &Ident, ) -> Name
Generate a name for the passed type ty identified by ident respecting the
configured type postfixes.
Sourcefn make_unknown_variant(&self, id: usize) -> Ident2
fn make_unknown_variant(&self, id: usize) -> Ident2
Create an unknown enum variant using the provided id.
The default implementation generated Unknown{id} here.