pub struct SessionLease { /* private fields */ }Expand description
A held single-writer lease on one session file. Dropping (or SessionLease::release)
drops the kernel lock, removes the advisory metadata and any pending takeover request.
The .lock file itself is left in place while the session file exists (POSIX locks name
an inode); it is removed when the session file does not exist (a lease eagerly taken for
a session that was never written), best-effort on Windows where a live byte-range lock
blocks deletion.
Implementations§
Source§impl SessionLease
impl SessionLease
Sourcepub fn acquire(
session_file: &Path,
holder: &LeaseInfo,
) -> Result<Self, SessionLockError>
pub fn acquire( session_file: &Path, holder: &LeaseInfo, ) -> Result<Self, SessionLockError>
Acquires the exclusive lease on session_file for holder. For a session file that
does not exist yet (new session, file created at the first flush) the parent directory
is created so the .lock sibling can claim the planned path before the file exists
(D-LOCK “lazily at the first flush … before the file is created”).
§Errors
SessionLockError::HeldBy when this process or another writer already holds it
(the info names the holder when the advisory metadata is readable);
SessionLockError::Io when the lock file cannot be created or locked.
Sourcepub fn session_file(&self) -> &Path
pub fn session_file(&self) -> &Path
The leased session file (resolved absolute path).