pub struct Marker { /* private fields */ }
Expand description
Implementations§
source§impl Marker
impl Marker
sourcepub fn acquire_to_hold_resource(
at_path: impl AsRef<Path>,
mode: Fail,
boundary_directory: Option<PathBuf>
) -> Result<Marker, Error>
pub fn acquire_to_hold_resource(
at_path: impl AsRef<Path>,
mode: Fail,
boundary_directory: Option<PathBuf>
) -> Result<Marker, Error>
Like acquire_to_update_resource()
but without the possibility to make changes
and commit them.
If boundary_directory
is given, non-existing directories will be created automatically and removed in the case of
a rollback.
source§impl Marker
impl Marker
sourcepub fn resource_path(&self) -> PathBuf
pub fn resource_path(&self) -> PathBuf
Return the path at which the locked resource resides
Examples found in repository?
src/commit.rs (line 49)
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
pub fn commit(mut self) -> Result<PathBuf, Error<Self>> {
if !self.created_from_file {
return Err(Error {
error: std::io::Error::new(
std::io::ErrorKind::Other,
"refusing to commit marker that was never opened",
),
instance: self,
});
}
let resource_path = self.resource_path();
match self.inner.persist(&resource_path) {
Ok(_) => Ok(resource_path),
Err(err) => Err(Error {
error: err.error,
instance: {
self.inner = err.handle;
self
},
}),
}
}