pub struct OperationIdGenerator { /* private fields */ }Expand description
Generate deterministic operation IDs for durable operations.
Each OperationIdGenerator maintains a monotonically increasing counter.
IDs are computed as blake2b(input) truncated to 64 hex characters, where
input is "{counter}" for root operations or "{parent_id}-{counter}"
for child operations.
§Determinism Invariant
The same code path executing the same sequence of durable operations must produce the same operation IDs across replays. This is the fundamental correctness requirement for the replay engine.
§Examples
use durable_lambda_core::operation_id::OperationIdGenerator;
let mut gen = OperationIdGenerator::new(None);
let id1 = gen.next_id();
let id2 = gen.next_id();
// IDs are deterministic — same counter produces same ID.
let mut gen2 = OperationIdGenerator::new(None);
assert_eq!(id1, gen2.next_id());
assert_eq!(id2, gen2.next_id());
// Different IDs for different counters.
assert_ne!(id1, id2);Implementations§
Source§impl OperationIdGenerator
impl OperationIdGenerator
Sourcepub fn new(parent_id: Option<String>) -> Self
pub fn new(parent_id: Option<String>) -> Self
Create a new generator, optionally scoped under a parent operation.
parent_id: None— root-level generator, hashes"{counter}"parent_id: Some(id)— child generator, hashes"{parent_id}-{counter}"
§Examples
use durable_lambda_core::operation_id::OperationIdGenerator;
// Root-level generator.
let root = OperationIdGenerator::new(None);
// Child generator scoped to a parent operation.
let child = OperationIdGenerator::new(Some("abc123".to_string()));Sourcepub fn next_id(&mut self) -> String
pub fn next_id(&mut self) -> String
Generate the next deterministic operation ID.
Increments the internal counter and returns a 64-character hex string
derived from blake2b hashing.
§Examples
use durable_lambda_core::operation_id::OperationIdGenerator;
let mut gen = OperationIdGenerator::new(None);
let id = gen.next_id();
assert_eq!(id.len(), 64);Trait Implementations§
Source§impl Clone for OperationIdGenerator
impl Clone for OperationIdGenerator
Source§fn clone(&self) -> OperationIdGenerator
fn clone(&self) -> OperationIdGenerator
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 moreAuto Trait Implementations§
impl Freeze for OperationIdGenerator
impl RefUnwindSafe for OperationIdGenerator
impl Send for OperationIdGenerator
impl Sync for OperationIdGenerator
impl Unpin for OperationIdGenerator
impl UnsafeUnpin for OperationIdGenerator
impl UnwindSafe for OperationIdGenerator
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreCreates a shared type from an unshared type.