pub trait ModelNaming {
// Provided methods
fn model_name() -> ModelName { ... }
fn model_name_instance(&self) -> ModelName { ... }
fn to_model(&self) -> &Self { ... }
fn singular(&self) -> String { ... }
fn plural(&self) -> String { ... }
fn route_key(&self) -> String { ... }
fn singular_route_key(&self) -> String { ... }
fn param_key(&self) -> String { ... }
fn uncountable() -> bool { ... }
fn human_attribute_name(attribute: &str) -> String { ... }
}Expand description
Model naming conventions shared across model-like types.
Override ModelNaming::model_name when a type needs custom naming metadata,
such as namespaced routing or a non-standard external name.
Provided Methods§
Sourcefn model_name() -> ModelName
fn model_name() -> ModelName
Returns cached naming metadata for the implementing type.
Sourcefn model_name_instance(&self) -> ModelName
fn model_name_instance(&self) -> ModelName
Returns cached naming metadata from an instance.
Sourcefn to_model(&self) -> &Self
fn to_model(&self) -> &Self
Mirrors Rails’ to_model naming helper for already-materialized records.
Sourcefn singular_route_key(&self) -> String
fn singular_route_key(&self) -> String
Returns the singular route key for a record instance.
Sourcefn uncountable() -> bool
fn uncountable() -> bool
Returns true when the model name is uncountable.
Sourcefn human_attribute_name(attribute: &str) -> String
fn human_attribute_name(attribute: &str) -> String
Returns a human-readable label for an attribute name.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.