pub struct SecurityContextId(/* private fields */);Expand description
Security context identifier value object for type-safe security management
This value object provides type-safe security context identification with security audit trails, compliance management, and comprehensive validation capabilities. It implements Domain-Driven Design (DDD) value object patterns with immutable semantics and security-specific features.
§Key Features
- Type Safety: Strongly-typed security context identifiers that cannot be confused with other IDs
- Security Audit Trails: ULID-based time-ordered creation sequence for security event tracking
- Compliance Management: Natural chronological ordering for audit trails and compliance reporting
- Cross-Platform: Consistent representation across languages and storage systems
- Security Validation: Comprehensive security-specific validation with expiration management
- Serialization: Full serialization support for storage and API integration
§Benefits Over Raw ULIDs
- Type Safety:
SecurityContextIdcannot be confused withPipelineIdor other entity IDs - Domain Semantics: Clear intent in function signatures and security business logic
- Security Validation: Security-specific validation rules with expiration and constraints
- Future Evolution: Extensible for security-specific methods and features
§Security Context Benefits
- Audit Trails: Natural time ordering for security events and compliance tracking
- Type Safety: Cannot be confused with other entity IDs in complex security workflows
- Compliance: Easy tracking of security context lifecycles for regulatory compliance
- Debugging: Clear identification of security context creation times for security investigations
- Expiration: Built-in expiration validation to prevent stale security contexts
§Usage Examples
§Cross-Language Mapping
- Rust:
SecurityContextIdnewtype wrapper with full validation - Go:
SecurityContextIDstruct with equivalent interface - JSON: String representation of ULID for API compatibility
- Database: TEXT column with ULID string storage
Implementations§
Source§impl SecurityContextId
impl SecurityContextId
Sourcepub fn from_ulid(ulid: Ulid) -> Result<Self, PipelineError>
pub fn from_ulid(ulid: Ulid) -> Result<Self, PipelineError>
Creates a security 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 security 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 security 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 security context ID using category-specific rules
Trait Implementations§
Source§impl AsRef<Ulid> for SecurityContextId
impl AsRef<Ulid> for SecurityContextId
Source§impl Clone for SecurityContextId
impl Clone for SecurityContextId
Source§fn clone(&self) -> SecurityContextId
fn clone(&self) -> SecurityContextId
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 SecurityContextId
impl Debug for SecurityContextId
Source§impl Default for SecurityContextId
impl Default for SecurityContextId
Source§impl<'de> Deserialize<'de> for SecurityContextId
impl<'de> Deserialize<'de> for SecurityContextId
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 SecurityContextId
impl Display for SecurityContextId
Source§impl From<SecurityContextId> for Ulid
impl From<SecurityContextId> for Ulid
Source§fn from(id: SecurityContextId) -> Self
fn from(id: SecurityContextId) -> Self
Converts to this type from the input type.
Source§impl From<Ulid> for SecurityContextId
impl From<Ulid> for SecurityContextId
Source§impl FromStr for SecurityContextId
impl FromStr for SecurityContextId
Source§impl Hash for SecurityContextId
impl Hash for SecurityContextId
Source§impl Ord for SecurityContextId
impl Ord for SecurityContextId
Source§fn cmp(&self, other: &SecurityContextId) -> Ordering
fn cmp(&self, other: &SecurityContextId) -> 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 SecurityContextId
impl PartialEq for SecurityContextId
Source§impl PartialOrd for SecurityContextId
impl PartialOrd for SecurityContextId
Source§impl Serialize for SecurityContextId
impl Serialize for SecurityContextId
impl Eq for SecurityContextId
impl StructuralPartialEq for SecurityContextId
Auto Trait Implementations§
impl Freeze for SecurityContextId
impl RefUnwindSafe for SecurityContextId
impl Send for SecurityContextId
impl Sync for SecurityContextId
impl Unpin for SecurityContextId
impl UnwindSafe for SecurityContextId
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