Struct git_lock::Marker

source ·
pub struct Marker { /* private fields */ }
Expand description

Locks a resource to allow related resources to be updated using files.

As opposed to the File type this one won’t keep the tempfile open for writing and thus consumes no system resources, nor can it be persisted.

Implementations§

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.

Commit the changes written to the previously open file and overwrite the original file atomically, returning the resource path on success.

This fails for markers which weren’t created with File::close()

Return the path at which the lock file resides

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
                },
            }),
        }
    }

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.