pub struct DotlockOptions { /* private fields */ }Expand description
Options which can be used to configure how a lock file is created.
This builder exposes the ability to configure how a lock file is
created. The Dotlock::create method is an alias for the
create method here.
To use DotlockOptions, first call new, then chain calls to
methods to set each option required, and finally call create
with the full path of the lock file to create. This will give you a
io::Result with a Dotlock inside.
§Examples
Create a lock file using the defaults:
use dotlock::DotlockOptions;
DotlockOptions::new().create("database.lock").unwrap();Create a lock file, but failing immediately if creating it fails, and remove lock files older than 5 minutes.
use dotlock::DotlockOptions;
use std::time::Duration;
DotlockOptions::new()
.tries(1)
.stale_age(Duration::from_secs(300))
.create("database.lock").unwrap();Implementations§
Source§impl DotlockOptions
impl DotlockOptions
Sourcepub fn pause<T: Into<Duration>>(self, pause: T) -> Self
pub fn pause<T: Into<Duration>>(self, pause: T) -> Self
Set the time Dotlock will pause between attempts to create the
lock file. Defaults to 5 seconds.
Sourcepub fn tries(self, tries: usize) -> Self
pub fn tries(self, tries: usize) -> Self
Set the number of times Dotlock will try to create the lock
file. Defaults to 10 times.
Sourcepub fn permissions(self, perm: Permissions) -> Self
pub fn permissions(self, perm: Permissions) -> Self
Set the permissions on the newly created lock file. If not set, the lock file permissions will be based on the current umask.