Skip to main content

NameBuilderExt

Trait NameBuilderExt 

Source
pub trait NameBuilderExt: Sized {
    // Required methods
    fn generate_id(self) -> Self;
    fn with_id(self, value: bool) -> Self;
    fn extend<I>(self, replace: bool, iter: I) -> Self
       where I: IntoIterator,
             I::Item: Display;
    fn remove_suffix(self, suffix: &str) -> Self;
    fn unique_name<T>(self, value: T) -> Self
       where T: Display;
    fn shared_name<T>(self, value: T) -> Self
       where T: Display;
    fn or<T>(self, fallback: T) -> Self
       where T: NameFallback;
    fn or_else<F, T>(self, fallback: F) -> Self
       where F: FnOnce() -> T,
             T: NameFallback;
    fn type_name(self) -> Self;
    fn field_name(self) -> Self;
    fn content_type_name(self) -> Self;
}
Expand description

Helper trait that provides additional builder patterns to the NameBuilder.

Required Methods§

Source

fn generate_id(self) -> Self

Force the builder to generate a unique id.

Source

fn with_id(self, value: bool) -> Self

Tell the builder to add (true) or not to add (false) the unique id to the generated name.

Source

fn extend<I>(self, replace: bool, iter: I) -> Self
where I: IntoIterator, I::Item: Display,

Add extensions to the builder using the passed iterator iter. If replace is set to true any existing extension is dropped before the new ones are applied.

Source

fn remove_suffix(self, suffix: &str) -> Self

Remove the specified suffix from the builder.

Source

fn unique_name<T>(self, value: T) -> Self
where T: Display,

Instruct the builder to create a unique name from the passed value.

This means, that the with_id is automatically set to false.

Source

fn shared_name<T>(self, value: T) -> Self
where T: Display,

Instruct the builder to create a name that is shared between different parts of the code from the passed value.

This means, that the with_id is automatically set to true and the generated name has a unique id to be identified.

Source

fn or<T>(self, fallback: T) -> Self
where T: NameFallback,

If the builder does currently not have a name, the passed fallback is applied.

Source

fn or_else<F, T>(self, fallback: F) -> Self
where F: FnOnce() -> T, T: NameFallback,

If the builder does currently not have a name, the passed fallback is applied.

Source

fn type_name(self) -> Self

Prepare the builder to create a type name.

Source

fn field_name(self) -> Self

Prepare the builder to create a field name.

Source

fn content_type_name(self) -> Self

Prepare the builder to create a content type name.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<X> NameBuilderExt for X
where X: NameBuilder + Sized,