Expand description
§Domain Value Objects
This module contains the domain value objects - immutable objects that represent concepts without identity. Value objects are defined by their attributes and enforce business rules through validation.
§Value Object Characteristics
All value objects in this system share these characteristics:
- Immutability: Cannot be modified after creation
- No Identity: Equality is based on attributes, not identity
- Self-Validating: Enforce business rules during construction
- Side-Effect Free: Operations don’t modify state
- Composable: Can be combined to create more complex concepts
§Core Value Objects
§Identifiers
Strongly-typed identifiers that prevent mixing different types of IDs:
PipelineId: Unique identifier for pipeline instancesStageId: Identifier for individual pipeline stagesFileChunkId: Identifier for file chunks in processingEncryptionKeyId: Identifier for encryption keysUserId: Identifier for user accounts and sessionsSessionId: Identifier for user sessionsProcessingContextId: Identifier for processing contextsSecurityContextId: Identifier for security contextsGenericId: Generic type-safe identifier system
§File Processing Objects
Objects representing file data and processing concepts:
FileChunk: Immutable file chunk with integrity validationChunkMetadata: Metadata for tracking and managing file chunksChunkSize: Type-safe chunk size with validation and optimizationGenericSize: Generic size value object with unit conversions
§Algorithm and Configuration Objects
Objects representing processing algorithms and their configurations:
Algorithm: Type-safe algorithm specification with validationProcessingStepDescriptor: Description of processing steps in pipelineStageParameters: Type-safe parameter management for pipeline stagesStageOrder: Ordering and sequencing of pipeline stagesWorkerCount: Validated worker count for parallel processing
§File System Objects
Objects representing file paths and permissions with type safety:
FilePath: Type-safe file paths with category-specific validationFilePermissions: Cross-platform file permission management
§Binary Format Objects
Objects representing the structure of processed files:
FileHeader: Binary file format header with integrity verificationChunkFormat: Format specification for chunk serializationProcessingStepType: Type enumeration for processing steps
§Security Objects
Objects representing security contexts and permissions:
SecurityContextId: Identifier for security contexts with expirationEncryptionKeyId: Type-safe encryption key identifiersEncryptionBenchmark: Performance metrics for encryption algorithms
§Processing Configuration Objects
Objects representing processing parameters and requirements:
PipelineRequirements: Configuration for pipeline performance and securityStageParameters: Type-safe parameters for individual stagesWorkerCount: Validated parallel worker configuration
§Validation and Business Rules
Value objects enforce business rules through validation:
§Validation Benefits
- Early Error Detection: Invalid values caught at construction
- No Invalid States: Impossible to create invalid value objects
- Clear Error Messages: Descriptive validation errors
- Type Safety: Compiler enforces validation requirements
§Composition and Transformation
Value objects can be composed and transformed safely:
§Transformation Patterns
- Immutable Transformations: Create new value objects instead of mutating
- Builder Pattern: Fluent construction of complex value objects
- Composition: Combine simple value objects into complex ones
- Type Conversion: Safe conversion between related types
§Serialization and Persistence
Value objects support serialization for persistence and communication:
§Serialization Features
- JSON Support: All value objects implement
SerializeandDeserialize - Type Safety: Deserialization validates constraints
- Cross-Platform: Consistent representation across languages
- Version Compatibility: Serialization format stability
§Testing Value Objects
Value objects are easily testable due to their immutability:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_value_object_equality() {
let id1 = String::new("test-pipeline").unwrap();
let id2 = String::new("test-pipeline").unwrap();
let id3 = String::new("other-pipeline").unwrap();
// Equality based on value, not identity
assert_eq!(id1, id2);
assert_ne!(id1, id3);
}
#[test]
fn test_value_object_immutability() {
let size = String::new(1024).unwrap();
let doubled = size.multiply(2).unwrap();
// Original value unchanged
assert_eq!(size.as_bytes(), 1024);
assert_eq!(doubled.as_bytes(), 2048);
}
#[test]
fn test_value_object_validation() {
// Valid values succeed
assert!(String::new(1024).is_ok());
// Invalid values fail
assert!(String::new(0).is_err());
}
}Re-exports§
pub use algorithm::Algorithm;pub use binary_file_format::ChunkFormat;pub use binary_file_format::FileHeader;pub use binary_file_format::ProcessingStepType;pub use chunk_metadata::ChunkMetadata;pub use chunk_size::ChunkSize;pub use encryption_benchmark::EncryptionBenchmark;pub use encryption_key_id::EncryptionKeyId;pub use file_chunk::FileChunk;pub use file_chunk_id::FileChunkId;pub use file_path::FilePath;pub use file_permissions::FilePermissions;pub use generic_id::GenericId;pub use generic_size::GenericSize;pub use pipeline_id::PipelineId;pub use pipeline_requirements::PipelineRequirements;pub use processing_context_id::ProcessingContextId;pub use processing_step_descriptor::ProcessingStepDescriptor;pub use security_context_id::SecurityContextId;pub use session_id::SessionId;pub use stage_id::StageId;pub use stage_order::StageOrder;pub use stage_parameters::StageParameters;pub use user_id::UserId;pub use worker_count::WorkerCount;
Modules§
- algorithm
- Algorithm Value Object
- binary_
file_ format - Binary File Format Value Object
- chunk_
metadata - Chunk Metadata Value Object
- chunk_
size - Chunk Size Value Object
- encryption_
benchmark - Encryption Benchmark Value Object
- encryption_
key_ id - Encryption Key Identifier Value Object - Security Infrastructure
- file_
chunk - File Chunk Value Object
- file_
chunk_ id - File Chunk Identifier Value Object - Processing Infrastructure
- file_
path - File Path Value Object
- file_
permissions - File Permissions Value Objects
- generic_
id - Generic ID Value Object
- generic_
size - Generic Size Value Object
- pipeline_
id - Pipeline Identifier Value Object - Core Infrastructure
- pipeline_
requirements - Pipeline Requirements Value Object
- processing_
context_ id - Processing Context Identifier Value Object - Request Tracing Infrastructure
- processing_
step_ descriptor - Processing Step Descriptor Value Object
- security_
context_ id - Security Context Identifier Value Object - Security Infrastructure
- session_
id - Session Identifier Value Object - Session Management Infrastructure
- stage_
id - Stage Identifier Value Object - Pipeline Stage Management Infrastructure
- stage_
order - Stage Order Value Object - Pipeline Stage Sequencing Infrastructure
- stage_
parameters - Stage Parameters Value Object - Pipeline Configuration Infrastructure
- user_id
- User ID Value Object - Authentication and Authorization Infrastructure
- worker_
count - Worker Count Value Object - Parallel Processing Optimization Infrastructure