pub(crate) trait KeySpecifierComponent {
    // Required methods
    fn to_slug(&self) -> Result<Slug, Bug>;
    fn from_slug(s: &Slug) -> Result<Self, InvalidKeyPathComponentValue>
       where Self: Sized;
    fn fmt_pretty(&self, f: &mut Formatter<'_>) -> Result<(), Error>;
}
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 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) -> Result<Self, InvalidKeyPathComponentValue>
where Self: Sized,

Try to convert s into an object of this type.

source

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

Display the value in a human-meaningful representation

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

Implementors§