pub trait KeySpecifierComponent {
    // Required methods
    fn to_component(&self) -> Result<Slug, Bug>;
    fn from_component(c: &Slug) -> StdResult<Self, InvalidKeyPathComponentValue>
       where Self: Sized;
    fn fmt_pretty(&self, f: &mut Formatter<'_>) -> Result;
}
Expand description

A trait for serializing and deserializing specific types of Slugs.

A KeySpecifierComponent is a specific kind of Slug. A KeySpecifierComponent is always a valid Slug, but may have a more restricted charset, or more specific validation rules. A Slug is not always a valid KeySpecifierComponent instance.

If you are deriving DefaultKeySpecifier for a struct, all of its fields must implement this trait.

If you are implementing KeySpecifier and KeyInfoExtractor manually rather than by deriving DefaultKeySpecifier, you do not need to implement this trait.

Required Methods§

source

fn to_component(&self) -> Result<Slug, Bug>

Return the Slug representation of this type.

source

fn from_component(c: &Slug) -> StdResult<Self, InvalidKeyPathComponentValue>
where Self: Sized,

Try to convert c into an object of this type.

source

fn fmt_pretty(&self, f: &mut Formatter<'_>) -> Result

Display the value in a human-meaningful representation

The output should be a single line (without trailing full stop).

Implementations on Foreign Types§

source§

impl KeySpecifierComponent for HsId

source§

fn to_component(&self) -> StdResult<Slug, Bug>

source§

fn from_component(s: &Slug) -> StdResult<Self, InvalidKeyPathComponentValue>
where Self: Sized,

source§

fn fmt_pretty(&self, f: &mut Formatter<'_>) -> Result

source§

impl KeySpecifierComponent for TimePeriod

source§

fn to_component(&self) -> Result<Slug, Bug>

source§

fn from_component(c: &Slug) -> StdResult<Self, InvalidKeyPathComponentValue>
where Self: Sized,

source§

fn fmt_pretty(&self, f: &mut Formatter<'_>) -> Result

Implementors§