Ops - Rust Ops Framework
Rust ops framework with dry/wet context separation and deferred execution.
Features
- Dry/Wet Context separation - serializable data vs runtime references
- Op metadata and schema validation for inputs, references, and outputs
- Deferred execution - save op requests for later execution
- Composable wrappers - logging and timeout decorators
- Batch operations - sequential and parallel execution
- Ergonomic macros - context access patterns
- Memory safety with zero-cost abstractions
Quick Start
Add to your Cargo.toml:
[]
= { = "." }
= { = "1.0", = ["full"] }
Basic Usage
use ;
use async_trait;
;
async
Wrapper Composition
use ;
use Duration;
let op = Boxnew;
let timeout_op = new;
let logged_op = new;
let dry = new.with_value;
let wet = new;
let result = logged_op.perform.await?;
Batch Operations
use ;
use Arc;
let ops: = vec!;
let mut dry = new.with_value;
let mut wet = new;
let batch = new;
let results = batch.perform.await?;
Architecture
Core Components
- Op Trait: Async trait with metadata and validation
- Dry/Wet Contexts: Separation of data from references
- Wrapper Pattern: Composable decorators
- Batch Operations: Sequential and parallel execution
- Deferred Execution: Save and execute later
Context System
- DryContext: Serializable data (can be persisted)
- WetContext: Runtime references (services, connections)
- Schema Validation: JSON Schema validation
- Deferred Execution: Save op requests for later
Macros
Ergonomic context access patterns:
use ;
// Dry context (serializable data)
dry_put!;
let name: String = dry_require!?;
// Wet context (runtime references)
wet_put_ref!;
let db: = wet_require_ref!?;
Available macros:
dry_put!,dry_get!,dry_require!,dry_result!wet_put_ref!,wet_put_arc!,wet_get_ref!,wet_require_ref!
Examples
Run examples to see the framework in action:
Schema Validation
Define input, reference, and output schemas:
// Validate contexts before execution
let validation = op.metadata.validate_contexts?;
if validation.is_valid
Testing
License
MIT License - see LICENSE file for details.