pub struct Algorithm(/* private fields */);Expand description
Value object representing a validated algorithm name
This value object encapsulates algorithm names with comprehensive validation to ensure they meet the required format and naming conventions.
§Key Features
- Name Validation: Comprehensive validation of algorithm names
- Format Normalization: Normalize names to lowercase
- Character Restrictions: Only alphanumeric, hyphens, and underscores
- Immutability: Algorithm names cannot be changed after creation
§Validation Rules
- Must be non-empty after trimming whitespace
- Must contain only alphanumeric characters, hyphens, and underscores
- Is normalized to lowercase for consistency
- Must match the pattern:
^[a-zA-Z0-9_-]+$
§Examples
Implementations§
Source§impl Algorithm
impl Algorithm
Sourcepub fn new(value: &str) -> Result<Self, PipelineError>
pub fn new(value: &str) -> Result<Self, PipelineError>
Create a new Algorithm with validation
§Purpose
Creates a validated algorithm name with format normalization. Ensures algorithm names follow consistent naming conventions.
§Why
Validated algorithm names provide:
- Prevention of configuration errors
- Consistent naming across systems
- Type-safe algorithm specification
- Cross-platform compatibility
§Arguments
value- Algorithm name (alphanumeric, hyphens, underscores)
§Returns
Ok(Algorithm)- Validated algorithm (normalized to lowercase)Err(PipelineError)- Invalid format
§Errors
- Empty name after trimming
- Invalid characters (only alphanumeric,
-,_allowed)
§Examples
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Convert to owned String
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Algorithm
impl<'de> Deserialize<'de> for Algorithm
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Algorithm
impl StructuralPartialEq for Algorithm
Auto Trait Implementations§
impl Freeze for Algorithm
impl RefUnwindSafe for Algorithm
impl Send for Algorithm
impl Sync for Algorithm
impl Unpin for Algorithm
impl UnwindSafe for Algorithm
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more