pub struct ProcessingContextId(/* private fields */);Expand description
Processing context identifier value object for type-safe context management
This value object provides type-safe processing context identification with request tracing, processing lifecycle management, and comprehensive validation capabilities. It implements Domain-Driven Design (DDD) value object patterns with immutable semantics.
§Key Features
- Type Safety: Strongly-typed processing context identifiers that cannot be confused with other IDs
- Request Tracing: ULID-based time-ordered creation sequence for request flow tracking
- Processing Lifecycle: Natural chronological ordering for audit trails and debugging
- Cross-Platform: Consistent representation across languages and storage systems
- Validation: Comprehensive context-specific validation and business rules
- Serialization: Full serialization support for storage and API integration
§Benefits Over Raw ULIDs
- Type Safety:
ProcessingContextIdcannot be confused withPipelineIdor other entity IDs - Domain Semantics: Clear intent in function signatures and business logic
- Validation: Context-specific validation rules and constraints
- Future Evolution: Extensible for context-specific methods and features
§Processing Context Benefits
- Request Tracing: Natural time ordering for request flows and processing sequences
- Type Safety: Cannot be confused with other entity IDs in complex processing workflows
- Audit Trails: Easy tracking of processing context lifecycles and state changes
- Debugging: Clear identification of context creation times for troubleshooting
§Usage Examples
§Cross-Language Mapping
- Rust:
ProcessingContextIdnewtype wrapper with full validation - Go:
ProcessingContextIDstruct with equivalent interface - JSON: String representation of ULID for API compatibility
- Database: TEXT column with ULID string storage
Implementations§
Source§impl ProcessingContextId
impl ProcessingContextId
Sourcepub fn from_ulid(ulid: Ulid) -> Result<Self, PipelineError>
pub fn from_ulid(ulid: Ulid) -> Result<Self, PipelineError>
Creates a processing context ID from an existing ULID
Sourcepub fn from_string(s: &str) -> Result<Self, PipelineError>
pub fn from_string(s: &str) -> Result<Self, PipelineError>
Creates a processing context ID from a string representation
Sourcepub fn from_timestamp_ms(timestamp_ms: u64) -> Self
pub fn from_timestamp_ms(timestamp_ms: u64) -> Self
Creates a processing context ID from a timestamp
Sourcepub fn timestamp_ms(&self) -> u64
pub fn timestamp_ms(&self) -> u64
Gets the timestamp component
Sourcepub fn validate(&self) -> Result<(), PipelineError>
pub fn validate(&self) -> Result<(), PipelineError>
Validates the processing context ID using category-specific rules
Trait Implementations§
Source§impl AsRef<Ulid> for ProcessingContextId
impl AsRef<Ulid> for ProcessingContextId
Source§impl Clone for ProcessingContextId
impl Clone for ProcessingContextId
Source§fn clone(&self) -> ProcessingContextId
fn clone(&self) -> ProcessingContextId
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ProcessingContextId
impl Debug for ProcessingContextId
Source§impl Default for ProcessingContextId
impl Default for ProcessingContextId
Source§impl<'de> Deserialize<'de> for ProcessingContextId
impl<'de> Deserialize<'de> for ProcessingContextId
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
Source§impl Display for ProcessingContextId
impl Display for ProcessingContextId
Source§impl From<ProcessingContextId> for Ulid
impl From<ProcessingContextId> for Ulid
Source§fn from(id: ProcessingContextId) -> Self
fn from(id: ProcessingContextId) -> Self
Converts to this type from the input type.
Source§impl From<Ulid> for ProcessingContextId
impl From<Ulid> for ProcessingContextId
Source§impl FromStr for ProcessingContextId
impl FromStr for ProcessingContextId
Source§impl Hash for ProcessingContextId
impl Hash for ProcessingContextId
Source§impl Ord for ProcessingContextId
impl Ord for ProcessingContextId
Source§fn cmp(&self, other: &ProcessingContextId) -> Ordering
fn cmp(&self, other: &ProcessingContextId) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for ProcessingContextId
impl PartialEq for ProcessingContextId
Source§impl PartialOrd for ProcessingContextId
impl PartialOrd for ProcessingContextId
Source§impl Serialize for ProcessingContextId
impl Serialize for ProcessingContextId
impl Eq for ProcessingContextId
impl StructuralPartialEq for ProcessingContextId
Auto Trait Implementations§
impl Freeze for ProcessingContextId
impl RefUnwindSafe for ProcessingContextId
impl Send for ProcessingContextId
impl Sync for ProcessingContextId
impl Unpin for ProcessingContextId
impl UnwindSafe for ProcessingContextId
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