Skip to main content

SqlHlcStorage

Struct SqlHlcStorage 

Source
pub struct SqlHlcStorage { /* private fields */ }
Expand description

Persistence for the clock register, scoped to a table-name prefix.

Implementations§

Source§

impl SqlHlcStorage

Source

pub async fn open(db: &dyn Db, prefix: &str) -> Result<Self, DbError>

Ensure the clock register exists and read its seed — the clock’s only read, done once at startup. prefix namespaces the table so multiple stores can share a database.

Trait Implementations§

Source§

impl HlcStorage for SqlHlcStorage

Source§

fn load(&self) -> Result<Option<u64>, Self::Error>

Return the seed cached at open. No I/O — the read already happened.

Source§

fn save(&self, sink: &mut Self::Sink, raw: u64) -> Result<(), Self::Error>

Enqueue the clock-state upsert into sink. Durable when the caller commits the sink. The packed u64 occupies the full 64-bit width (48-bit millis << 16 | 16-bit counter), so DbValue::from_u64 rejects a value past i64::MAX rather than wrap it negative — which would also break the signed MAX-guard merge. The real clock stays far below that bound (millis below 2^47, ~year 6400).

Source§

type Error = DbError

Backend error type surfaced through the service’s results.
Source§

type Sink = dyn DbBatch

The transaction/batch save enqueues into (e.g. a DbBatch). ?Sized so a backend can use a trait object (dyn DbBatch).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.