pub enum FileLocking {
Enabled,
Disabled,
BestEffort,
}Expand description
File-locking policy applied at file open time.
§Platform notes
On Unix (flock(2) / fcntl(F_OFD_SETLK)) the lock is advisory:
a handle without a lock can still read and write a file that another
handle has locked. Setting FileLocking::Disabled or
FileLocking::BestEffort therefore lets the opener bypass another
process’s lock at the cost of safety.
On Windows (LockFileEx) the lock is mandatory: while one
handle holds an exclusive range lock, no other handle (regardless
of locking policy) can read or write that range — WriteFile and
ReadFile return ERROR_LOCK_VIOLATION (33). Disabled and
BestEffort only control whether we try to acquire a lock, not
whether the OS enforces locks held by other handles. The HDF5 C
library has the same limitation on Windows.
Variants§
Enabled
Acquire the lock; fail to open if it cannot be acquired (the HDF5 C-library default).
Disabled
Skip locking entirely. On Windows, OS-level locks held by other handles still apply.
BestEffort
Try to acquire the lock; if the filesystem doesn’t support
locking (e.g. NFS), proceed without one. On Unix this also
proceeds when the lock is contended; on Windows the resulting
reads/writes still fail at the OS level if another handle holds
a conflicting LockFileEx lock.
Implementations§
Source§impl FileLocking
impl FileLocking
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Returns the policy implied by the HDF5_USE_FILE_LOCKING
environment variable, falling back to FileLocking::Enabled.
Sourcepub fn from_env_or(default: FileLocking) -> Self
pub fn from_env_or(default: FileLocking) -> Self
Returns the policy implied by the env var if set, otherwise default.
Trait Implementations§
Source§impl Clone for FileLocking
impl Clone for FileLocking
Source§fn clone(&self) -> FileLocking
fn clone(&self) -> FileLocking
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FileLocking
impl Debug for FileLocking
Source§impl Default for FileLocking
impl Default for FileLocking
Source§fn default() -> FileLocking
fn default() -> FileLocking
Source§impl PartialEq for FileLocking
impl PartialEq for FileLocking
Source§fn eq(&self, other: &FileLocking) -> bool
fn eq(&self, other: &FileLocking) -> bool
self and other values to be equal, and is used by ==.