pub struct IdentifierDomain;Expand description
A strict domain for identifiers that must follow strict naming rules
This domain is suitable for cases where keys must be valid identifiers in programming languages or databases:
- Must start with a letter or underscore
- Can contain letters, numbers, and underscores only
- Case-sensitive
- No consecutive underscores
§Examples
use domain_key::{Key, IdentifierDomain};
type IdKey = Key<IdentifierDomain>;
let key = IdKey::new("valid_identifier")?;
assert_eq!(key.as_str(), "valid_identifier");Trait Implementations§
Source§impl Debug for IdentifierDomain
impl Debug for IdentifierDomain
Source§impl Domain for IdentifierDomain
impl Domain for IdentifierDomain
Source§const DOMAIN_NAME: &'static str = "identifier"
const DOMAIN_NAME: &'static str = "identifier"
Human-readable name for this domain Read more
Source§impl KeyDomain for IdentifierDomain
impl KeyDomain for IdentifierDomain
Source§const MAX_LENGTH: usize = 64
const MAX_LENGTH: usize = 64
Maximum length for keys in this domain Read more
Source§const EXPECTED_LENGTH: usize = 20
const EXPECTED_LENGTH: usize = 20
Optimization hint: expected average key length for this domain Read more
Source§const TYPICALLY_SHORT: bool = true
const TYPICALLY_SHORT: bool = true
Optimization hint: whether keys in this domain are typically short (≤32 chars) Read more
Source§const CASE_INSENSITIVE: bool = false
const CASE_INSENSITIVE: bool = false
Whether keys in this domain are case-insensitive Read more
Source§const HAS_CUSTOM_VALIDATION: bool = true
const HAS_CUSTOM_VALIDATION: bool = true
Whether this domain has custom validation rules Read more
Source§fn allowed_characters(c: char) -> bool
fn allowed_characters(c: char) -> bool
Check which characters are allowed for this domain Read more
Source§fn allowed_start_character(c: char) -> bool
fn allowed_start_character(c: char) -> bool
Check if a character is allowed at the start of a key Read more
Source§fn validate_domain_rules(key: &str) -> Result<(), KeyParseError>
fn validate_domain_rules(key: &str) -> Result<(), KeyParseError>
Domain-specific validation rules Read more
Source§fn validation_help() -> Option<&'static str>
fn validation_help() -> Option<&'static str>
Get domain-specific help text for validation errors Read more
Source§const HAS_CUSTOM_NORMALIZATION: bool = false
const HAS_CUSTOM_NORMALIZATION: bool = false
Whether this domain has custom normalization rules Read more
Source§const FREQUENTLY_COMPARED: bool = false
const FREQUENTLY_COMPARED: bool = false
Optimization hint: whether keys in this domain are frequently compared Read more
Source§const FREQUENTLY_SPLIT: bool = false
const FREQUENTLY_SPLIT: bool = false
Optimization hint: whether keys in this domain are frequently split Read more
Source§fn normalize_domain(key: Cow<'_, str>) -> Cow<'_, str>
fn normalize_domain(key: Cow<'_, str>) -> Cow<'_, str>
Domain-specific normalization Read more
Source§fn is_reserved_prefix(_key: &str) -> bool
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
fn is_reserved_suffix(_key: &str) -> bool
Check if a key has a reserved suffix for this domain Read more
Source§fn default_separator() -> char
fn default_separator() -> char
Get the default separator character for this domain Read more
Source§fn requires_ascii_only(_key: &str) -> bool
fn requires_ascii_only(_key: &str) -> bool
Check if the key contains only ASCII characters Read more
Source§fn min_length() -> usize
fn min_length() -> usize
Get the minimum allowed length for keys in this domain Read more
Auto Trait Implementations§
impl Freeze for IdentifierDomain
impl RefUnwindSafe for IdentifierDomain
impl Send for IdentifierDomain
impl Sync for IdentifierDomain
impl Unpin for IdentifierDomain
impl UnsafeUnpin for IdentifierDomain
impl UnwindSafe for IdentifierDomain
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more