pub trait Timestamp:
DBData
+ PartialOrder
+ Lattice {
type Nested: Timestamp;
type TimedBatch<B: Batch<Time = ()>>: Batch<Key = B::Key, Val = B::Val, Time = Self, R = B::R>;
const NESTING_DEPTH: usize;
// Required methods
fn minimum() -> Self;
fn advance(&self, scope: Scope) -> Self;
fn checked_recede(&self, scope: Scope) -> Option<Self>;
fn epoch_start(&self, scope: Scope) -> Self;
fn epoch_end(&self, scope: Scope) -> Self;
// Provided methods
fn clock_start() -> Self { ... }
fn recede(&self, scope: Scope) -> Self { ... }
}Expand description
Logical timestamp.
See crate documentation for an overview of logical time in DBSP.
Required Associated Constants§
Sourceconst NESTING_DEPTH: usize
const NESTING_DEPTH: usize
Nesting depth of the circuit running this clock.
0 - for the top-level clock, 1 - first-level nested circuit, etc.
Required Associated Types§
Required Methods§
fn minimum() -> Self
Sourcefn advance(&self, scope: Scope) -> Self
fn advance(&self, scope: Scope) -> Self
Advance the timestamp by one clock tick.
Advance self by one clock tick by incrementing the clock at the
specified nesting level by one, while resetting all clocks at deeper
nesting levels to 0. scope identifies the nesting level of the
circuit whose clock is ticking. 0 refers to the innermost
circuit. 1 is its parent circuit, etc. Returns the most accurate
approximation of the new timestamp value supported by this time
representation.
§Example
Assume a two-dimensional time modeled as (parent time, child time) tuple.
assert_eq!((2, 3).advance(0), (2, 4));
assert_eq!((2, 3).advance(1), (3, 0));Sourcefn checked_recede(&self, scope: Scope) -> Option<Self>
fn checked_recede(&self, scope: Scope) -> Option<Self>
Like recede, but returns None if the clock at level scope is
equal to zero (i.e., we are running the first clock cycle) and hence
cannot be decremented.
Sourcefn epoch_start(&self, scope: Scope) -> Self
fn epoch_start(&self, scope: Scope) -> Self
Returns the first time stamp of the current clock epoch in scope.
Provided Methods§
Sourcefn clock_start() -> Self
fn clock_start() -> Self
The value of the timestamp when the clock starts ticking.
This is typically but not always equal to Self::minimum. For example,
we use 1-bit timestamp that starts at value 1 (current clock epoch),
value 0 (previous epochs) can only be obtained by calling
recede.
Sourcefn recede(&self, scope: Scope) -> Self
fn recede(&self, scope: Scope) -> Self
Push the timestamp back by one clock tick.
Push self back by one clock cycle by decrementing the clock at the
specified nesting level by one. scope identifies the nesting
level of the circuit whose clock is ticking. 0 refers to the
innermost circuit. 1 is its parent circuit, etc.
§Panics
Panics if the clock at the scope nesting level is equal to zero
(i.e., we are running the first clock cycle) and hence cannot be
decremented.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.