Skip to main content

PathDomain

Struct PathDomain 

Source
pub struct PathDomain;
Expand description

A domain for file path-like keys

This domain allows forward slashes and is suitable for hierarchical keys that resemble file paths:

  • Allows alphanumeric, underscore, hyphen, dot, and forward slash
  • Case-insensitive
  • No consecutive slashes
  • Cannot start or end with slash

§Examples

use domain_key::{Key, PathDomain};

type PathKey = Key<PathDomain>;

let key = PathKey::new("users/profile/settings")?;
assert_eq!(key.as_str(), "users/profile/settings");

Trait Implementations§

Source§

impl Debug for PathDomain

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Domain for PathDomain

Source§

const DOMAIN_NAME: &'static str = "path"

Human-readable name for this domain Read more
Source§

impl KeyDomain for PathDomain

Source§

const MAX_LENGTH: usize = 256

Maximum length for keys in this domain Read more
Source§

const EXPECTED_LENGTH: usize = 48

Optimization hint: expected average key length for this domain Read more
Source§

const TYPICALLY_SHORT: bool = false

Optimization hint: whether keys in this domain are typically short (≤32 chars) Read more
Source§

const CASE_INSENSITIVE: bool = true

Whether keys in this domain are case-insensitive Read more
Source§

const FREQUENTLY_SPLIT: bool = true

Optimization hint: whether keys in this domain are frequently split Read more
Source§

const HAS_CUSTOM_VALIDATION: bool = true

Whether this domain has custom validation rules Read more
Source§

fn allowed_characters(c: char) -> bool

Check which characters are allowed for this domain Read more
Source§

fn allowed_start_character(c: char) -> bool

Check if a character is allowed at the start of a key Read more
Source§

fn allowed_end_character(c: char) -> bool

Check if a character is allowed at the end of a key Read more
Source§

fn allowed_consecutive_characters(prev: char, curr: char) -> bool

Check if two consecutive characters are allowed Read more
Source§

fn default_separator() -> char

Get the default separator character for this domain Read more
Source§

fn validate_domain_rules(key: &str) -> Result<(), KeyParseError>

Domain-specific validation rules Read more
Source§

fn validation_help() -> Option<&'static str>

Get domain-specific help text for validation errors Read more
Source§

fn examples() -> &'static [&'static str]

Get examples of valid keys for this domain Read more
Source§

const HAS_CUSTOM_NORMALIZATION: bool = false

Whether this domain has custom normalization rules Read more
Source§

const FREQUENTLY_COMPARED: bool = false

Optimization hint: whether keys in this domain are frequently compared Read more
Source§

fn normalize_domain(key: Cow<'_, str>) -> Cow<'_, str>

Domain-specific normalization Read more
Source§

fn is_reserved_prefix(_key: &str) -> bool

Check if a key has a reserved prefix for this domain Read more
Source§

fn is_reserved_suffix(_key: &str) -> bool

Check if a key has a reserved suffix for this domain Read more
Source§

fn requires_ascii_only(_key: &str) -> bool

Check if the key contains only ASCII characters Read more
Source§

fn min_length() -> usize

Get the minimum allowed length for keys in this domain Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.