pub struct PidLock { /* private fields */ }Expand description
Exclusive process lock protecting the redb-backed node.
Implementations§
Source§impl PidLock
impl PidLock
pub fn new(data_dir: &Path) -> Self
Sourcepub fn try_acquire(&self) -> Result<bool>
pub fn try_acquire(&self) -> Result<bool>
Try to acquire and retain the lock for this process.
The PID is written only after the OS-level lock succeeds. A false
result means another process currently owns the lock.
§Errors
Returns an error when the lock file cannot be opened or updated.
Sourcepub fn release(&self) -> Result<()>
pub fn release(&self) -> Result<()>
Release the lock held by this instance.
§Errors
Returns an error when the OS refuses to release the lock.
Sourcepub fn owner_pid(&self) -> Result<Option<u32>>
pub fn owner_pid(&self) -> Result<Option<u32>>
Read the last PID written to the lock file.
§Errors
Returns an error when the lock file cannot be read or its contents are not a decimal process ID.
pub fn lock_path(&self) -> &Path
pub fn state_path(&self) -> &Path
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for PidLock
impl RefUnwindSafe for PidLock
impl Send for PidLock
impl Sync for PidLock
impl Unpin for PidLock
impl UnsafeUnpin for PidLock
impl UnwindSafe for PidLock
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> 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