Skip to main content

Conversion

Trait Conversion 

Source
pub trait Conversion: Attributes + ModelNaming {
    // Provided methods
    fn to_key(&self) -> Option<Vec<Value>> { ... }
    fn param_delimiter() -> &'static str { ... }
    fn to_param(&self) -> Option<String> { ... }
    fn to_partial_path(&self) -> String { ... }
    fn model_name_for_conversion() -> &'static str { ... }
}
Expand description

Helpers for converting models into routing-friendly representations.

Provided Methods§

Source

fn to_key(&self) -> Option<Vec<Value>>

Returns the model key as a list of values.

The default implementation reads the id attribute and returns it when present and non-null.

Source

fn param_delimiter() -> &'static str

Returns the delimiter used when joining composite key components.

Source

fn to_param(&self) -> Option<String>

Returns a URL-safe parameter string derived from Conversion::to_key.

Source

fn to_partial_path(&self) -> String

Returns the partial template path for the model.

Source

fn model_name_for_conversion() -> &'static str

Returns the model name used by conversion helpers.

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.

Implementors§