pub struct Timestamp(/* private fields */);Expand description
A logical timestamp marking a point in a database’s commit history.
Timestamps are issued by the database as a strictly increasing sequence.
Timestamp::ZERO is the timestamp of the empty database before any commit;
a reader that begins against an empty database reads at ZERO and sees
nothing. The first commit is stamped 1, the next 2, and so on.
The type is Copy and totally ordered, so comparing visibility is a single
integer compare on the hot read path.
§Examples
use txn_db::Timestamp;
let t = Timestamp::ZERO;
assert_eq!(t.get(), 0);
assert!(Timestamp::ZERO < Timestamp::from_raw(1));Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub const ZERO: Timestamp
pub const ZERO: Timestamp
The timestamp of the empty database, before any transaction has
committed. A snapshot taken at ZERO observes no keys.
Sourcepub const fn from_raw(value: u64) -> Self
pub const fn from_raw(value: u64) -> Self
Wrap a raw counter value as a timestamp.
This is the inverse of Timestamp::get and exists for tests,
serialization of the commit log, and custom
VersionStore implementations that persist
timestamps. Application code rarely constructs timestamps directly — the
database issues them.
§Examples
use txn_db::Timestamp;
let ts = Timestamp::from_raw(42);
assert_eq!(ts.get(), 42);