Skip to main content

DeviceJoinJournalStore

Struct DeviceJoinJournalStore 

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

The joining device’s own journal of in-flight join attempts, kept in its own SQLite file under the stores root because the Store database it is joining does not exist yet while the attempt runs.

The file lives exactly as long as the attempts in it. Retiring the last row closes the connection and deletes the file with its WAL sidecars, so a device that has joined a store does not leave a dead journal behind forever; the next attempt reopens the path and gets a new file.

Implementations§

Source§

impl DeviceJoinJournalStore

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self, DbError>

Source

pub fn open_for_test(path: impl AsRef<Path>) -> Result<Self, DbError>

Source

pub fn insert_or_load( &self, attempt_id: &str, role: &str, payload: &str, ) -> Result<String, DbError>

Source

pub fn load( &self, attempt_id: &str, role: &str, ) -> Result<Option<String>, DbError>

Source

pub fn records(&self) -> Result<Vec<(String, String, String)>, DbError>

Source

pub fn compare_and_swap( &self, attempt_id: &str, role: &str, previous_payload: &str, next_payload: &str, ) -> Result<bool, DbError>

Source

pub fn compare_and_forget( &self, attempt_id: &str, role: &str, expected_payload: &str, ) -> Result<bool, DbError>

Drop one attempt’s joiner row, but only while it still holds exactly the payload the caller last read, and delete the journal file when that row was the last one in it.

This is how a joining device finishes: the row is its working notes on an exchange that is over, and what says the join happened is the library’s own config file, written before this runs. An emptied journal answers nothing either, so the file goes with the row rather than accumulating one dead SQLite database per store the device ever joined.

The row delete, the emptiness check, and the unlink all happen under the one connection lock, so a row begun by another attempt cannot land in a file that is about to be deleted.

Trait Implementations§

Source§

impl Clone for DeviceJoinJournalStore

Source§

fn clone(&self) -> DeviceJoinJournalStore

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DeviceJoinJournalStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,