Skip to main content

IntoKey

Trait IntoKey 

Source
pub trait IntoKey<T: KeyDomain> {
    // Required methods
    fn into_key(self) -> Result<Key<T>, KeyParseError>;
    fn try_into_key(self) -> Option<Key<T>>;
}
Expand description

Helper trait for converting strings to keys

This trait provides convenient methods for converting various string types into keys with proper error handling.

Required Methods§

Source

fn into_key(self) -> Result<Key<T>, KeyParseError>

Convert into a key, returning an error if validation fails

§Errors

Returns KeyParseError if the string fails validation for the domain

Source

fn try_into_key(self) -> Option<Key<T>>

Convert into a key, returning None if validation fails

This is useful when you want to filter out invalid keys rather than handle errors explicitly.

Implementations on Foreign Types§

Source§

impl<T: KeyDomain> IntoKey<T> for &str

Source§

impl<T: KeyDomain> IntoKey<T> for &String

Source§

impl<T: KeyDomain> IntoKey<T> for String

Implementors§