Trait KeySpecifierComponent

Source
pub trait KeySpecifierComponent {
    // Required methods
    fn to_slug(&self) -> Result<Slug, Bug>;
    fn from_slug(s: &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 [Slug]s.

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 KeyPathInfoExtractor manually rather than by deriving DefaultKeySpecifier, you do not need to implement this trait.

Required Methods§

Source

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

Return the [Slug] representation of this type.

Source

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

Try to convert s 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_slug(&self) -> StdResult<Slug, Bug>

Source§

fn from_slug(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_slug(&self) -> Result<Slug, Bug>

Source§

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

Source§

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

Implementors§