pub struct FileChunkId(/* private fields */);Expand description
File chunk identifier value object for type-safe chunk management
This value object provides type-safe file chunk identification with temporal ordering, processing sequence management, and comprehensive validation capabilities. It implements Domain-Driven Design (DDD) value object patterns with immutable semantics.
§Key Features
- Type Safety: Strongly-typed chunk identifiers that cannot be confused with other IDs
- Temporal Ordering: ULID-based time-ordered creation sequence for chunk processing
- Processing Sequence: Natural chronological ordering for deterministic processing
- Traceability: Complete chunk lifecycle tracking and debugging support
- Validation: Comprehensive chunk-specific validation and business rules
- Serialization: Consistent serialization across storage backends and APIs
§Temporal Ordering Benefits
The ULID-based approach provides several advantages for chunk processing:
- Processing Order: Natural time ordering ensures chunks are processed in sequence
- Deterministic Behavior: Consistent processing order across system restarts
- Debugging Support: Easy identification of chunk creation times and sequences
- Audit Trail: Complete chronological history of chunk processing
§Usage Examples
§Cross-Platform Compatibility
- Rust:
FileChunkIdnewtype wrapper with full validation - Go:
FileChunkIDstruct with equivalent interface - JSON: String representation of ULID for API compatibility
- Database: TEXT column with ULID string storage
Implementations§
Source§impl FileChunkId
impl FileChunkId
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new file chunk ID with current timestamp
§Purpose
Generates a unique, time-ordered file chunk identifier using ULID. Each chunk ID captures the exact moment of chunk creation for processing order.
§Why
Time-ordered chunk IDs provide:
- Natural chronological processing order
- Deterministic chunk sequence across restarts
- Built-in creation timestamp for monitoring
- Debugging support with temporal information
§Returns
New FileChunkId 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 file chunk 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 file chunk 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 file chunk 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 file chunk ID
Trait Implementations§
Source§impl AsRef<Ulid> for FileChunkId
impl AsRef<Ulid> for FileChunkId
Source§impl Clone for FileChunkId
impl Clone for FileChunkId
Source§fn clone(&self) -> FileChunkId
fn clone(&self) -> FileChunkId
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FileChunkId
impl Debug for FileChunkId
Source§impl Default for FileChunkId
impl Default for FileChunkId
Source§impl<'de> Deserialize<'de> for FileChunkId
impl<'de> Deserialize<'de> for FileChunkId
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 FileChunkId
impl Display for FileChunkId
Source§impl From<FileChunkId> for Ulid
impl From<FileChunkId> for Ulid
Source§fn from(id: FileChunkId) -> Self
fn from(id: FileChunkId) -> Self
Source§impl From<Ulid> for FileChunkId
impl From<Ulid> for FileChunkId
Source§impl FromStr for FileChunkId
impl FromStr for FileChunkId
Source§impl Hash for FileChunkId
impl Hash for FileChunkId
Source§impl Ord for FileChunkId
impl Ord for FileChunkId
Source§fn cmp(&self, other: &FileChunkId) -> Ordering
fn cmp(&self, other: &FileChunkId) -> 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 FileChunkId
impl PartialEq for FileChunkId
Source§impl PartialOrd for FileChunkId
impl PartialOrd for FileChunkId
Source§impl Serialize for FileChunkId
impl Serialize for FileChunkId
impl Eq for FileChunkId
impl StructuralPartialEq for FileChunkId
Auto Trait Implementations§
impl Freeze for FileChunkId
impl RefUnwindSafe for FileChunkId
impl Send for FileChunkId
impl Sync for FileChunkId
impl Unpin for FileChunkId
impl UnwindSafe for FileChunkId
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