pub struct StateFile { /* private fields */ }Expand description
SQLite-backed persistence for daemon state and status.
Implementations§
Source§impl StateFile
impl StateFile
Sourcepub fn new(data_dir: &Path) -> Self
pub fn new(data_dir: &Path) -> Self
Store the data directory path. The database is not opened yet —
call db() to open it lazily.
Sourcepub fn save(&self, state: &DaemonState) -> Result<()>
pub fn save(&self, state: &DaemonState) -> Result<()>
Sourcepub fn load(&self) -> Result<Option<DaemonState>>
pub fn load(&self) -> Result<Option<DaemonState>>
Load the daemon lifecycle state, returning None if absent.
§Errors
Returns an error when the database cannot be read.
Sourcepub fn save_status(&self, report: &DaemonStatusReport) -> Result<()>
pub fn save_status(&self, report: &DaemonStatusReport) -> Result<()>
Persist the current daemon activity report.
§Errors
Returns an error when the database cannot be written.
Sourcepub fn load_status(&self) -> Result<Option<DaemonStatusReport>>
pub fn load_status(&self) -> Result<Option<DaemonStatusReport>>
Sourcepub fn exists(&self) -> bool
pub fn exists(&self) -> bool
Check whether a lifecycle row exists (equivalent to the old file check).
Sourcepub fn remove_status(&self) -> Result<()>
pub fn remove_status(&self) -> Result<()>
Sourcepub fn is_running(&self) -> Result<bool>
pub fn is_running(&self) -> Result<bool>
Return whether the stored lifecycle indicates a still-running daemon.
§Errors
Returns an error when the database cannot be read.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StateFile
impl RefUnwindSafe for StateFile
impl Send for StateFile
impl Sync for StateFile
impl Unpin for StateFile
impl UnsafeUnpin for StateFile
impl UnwindSafe for StateFile
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 more