pub struct PipelineId(/* private fields */);Expand description
Pipeline entity identifier value object for type-safe pipeline management
This value object provides type-safe pipeline identification with temporal ordering, pipeline lifecycle management, and comprehensive validation capabilities. It implements Domain-Driven Design (DDD) value object patterns with immutable semantics.
§Key Features
- Type Safety: Strongly-typed pipeline identifiers that cannot be confused with other IDs
- Temporal Ordering: ULID-based time-ordered creation sequence for pipeline management
- Pipeline Lifecycle: Natural chronological ordering for audit trails and processing
- Cross-Platform: Consistent representation across languages and storage systems
- Validation: Comprehensive pipeline-specific validation and business rules
- Serialization: Full serialization support for storage and API integration
§Benefits Over Raw ULIDs
- Type Safety:
PipelineIdcannot be confused withStageIdor other entity IDs - Domain Semantics: Clear intent in function signatures and business logic
- Validation: Pipeline-specific validation rules and constraints
- Future Evolution: Extensible for pipeline-specific methods and features
§Usage Examples
§Cross-Language Mapping
- Rust:
PipelineIdnewtype wrapper with full validation - Go:
PipelineIDstruct with equivalent interface - JSON: String representation of ULID for API compatibility
- Database: TEXT column with ULID string storage
Implementations§
Source§impl PipelineId
impl PipelineId
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new pipeline ID with current timestamp
§Purpose
Generates a unique, time-ordered pipeline identifier using ULID. Each ID captures the exact moment of pipeline creation.
§Why
Time-ordered pipeline IDs provide:
- Natural chronological sorting for audit trails
- Efficient range queries by creation time
- Guaranteed uniqueness with 128-bit randomness
- No coordination needed across distributed systems
§Time Ordering
Pipeline IDs are naturally sorted by creation time, making them perfect for chronological pipeline processing and audit trails.
§Returns
New PipelineId with current millisecond timestamp
§Examples
Sourcepub fn from_ulid(ulid: Ulid) -> Result<Self, PipelineError>
pub fn from_ulid(ulid: Ulid) -> Result<Self, PipelineError>
Creates a pipeline ID from an existing ULID
§Use Cases
- Deserializing from database
- Converting from external systems
- Testing with known IDs
Sourcepub fn from_string(s: &str) -> Result<Self, PipelineError>
pub fn from_string(s: &str) -> Result<Self, PipelineError>
Creates a pipeline ID from a string representation
§Purpose
Parses and validates a pipeline ID from its ULID string representation. Used for deserialization, API input, and database retrieval.
§Why
String parsing enables:
- RESTful API integration
- Database round-trip serialization
- Configuration file support
- Cross-language interoperability
§Format
Accepts standard ULID string format (26 characters, base32 encoded) Example: “01ARZ3NDEKTSV4RRFFQ69G5FAV”
§Arguments
s- ULID string (26 characters, Crockford Base32)
§Returns
Ok(PipelineId)- Valid pipeline IDErr(PipelineError::InvalidConfiguration)- Invalid ULID format
§Errors
Returns PipelineError::InvalidConfiguration when:
- String is not 26 characters
- Contains invalid Base32 characters
- Validation rules fail
§Examples
Sourcepub fn from_timestamp_ms(timestamp_ms: u64) -> Self
pub fn from_timestamp_ms(timestamp_ms: u64) -> Self
Creates a pipeline ID from a timestamp (useful for range queries)
§Purpose
Generates a pipeline ID with a specific timestamp. Primary use case is creating boundary IDs for time-range queries.
§Why
Timestamp-based IDs enable:
- Efficient time-range queries (“created after midnight”)
- Time-based pagination in databases
- Migration from timestamp-based systems
- Reproducible IDs for testing
§Arguments
timestamp_ms- Milliseconds since Unix epoch
§Returns
PipelineId with specified timestamp (random component generated)
§Use Cases
- Creating boundary IDs for time-range queries
- “Find all pipelines created after midnight”
- Time-based pagination
- Migration from timestamp-based systems
§Examples
Sourcepub fn as_ulid(&self) -> Ulid
pub fn as_ulid(&self) -> Ulid
Gets the underlying ULID value
§Use Cases
- Database storage
- External API integration
- Logging and debugging
Sourcepub fn timestamp_ms(&self) -> u64
pub fn timestamp_ms(&self) -> u64
Sourcepub fn datetime(&self) -> DateTime<Utc>
pub fn datetime(&self) -> DateTime<Utc>
Gets the creation time as a DateTime
§Use Cases
- Human-readable timestamps in logs
- Time-based filtering in UI
- Audit reports
Sourcepub fn to_lowercase(&self) -> String
pub fn to_lowercase(&self) -> String
Converts to lowercase string representation
§Use Cases
- Case-insensitive systems
- URL paths
- Database systems that prefer lowercase
Trait Implementations§
Source§impl AsRef<Ulid> for PipelineId
impl AsRef<Ulid> for PipelineId
Source§impl Clone for PipelineId
impl Clone for PipelineId
Source§fn clone(&self) -> PipelineId
fn clone(&self) -> PipelineId
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PipelineId
impl Debug for PipelineId
Source§impl Default for PipelineId
impl Default for PipelineId
Source§impl<'de> Deserialize<'de> for PipelineId
impl<'de> Deserialize<'de> for PipelineId
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>,
Source§impl Display for PipelineId
impl Display for PipelineId
Source§impl From<PipelineId> for Ulid
impl From<PipelineId> for Ulid
Source§fn from(id: PipelineId) -> Self
fn from(id: PipelineId) -> Self
Source§impl From<Ulid> for PipelineId
impl From<Ulid> for PipelineId
Source§impl FromStr for PipelineId
impl FromStr for PipelineId
Source§impl Hash for PipelineId
impl Hash for PipelineId
Source§impl Ord for PipelineId
impl Ord for PipelineId
Source§fn cmp(&self, other: &PipelineId) -> Ordering
fn cmp(&self, other: &PipelineId) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for PipelineId
impl PartialEq for PipelineId
Source§impl PartialOrd for PipelineId
impl PartialOrd for PipelineId
Source§impl Serialize for PipelineId
impl Serialize for PipelineId
impl Eq for PipelineId
impl StructuralPartialEq for PipelineId
Auto Trait Implementations§
impl Freeze for PipelineId
impl RefUnwindSafe for PipelineId
impl Send for PipelineId
impl Sync for PipelineId
impl Unpin for PipelineId
impl UnwindSafe for PipelineId
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
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>
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>
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