Struct warg_client::lock::FileLock
source · pub struct FileLock { /* private fields */ }Expand description
A file system lock.
This implementation is modeled after the FileLock type in the cargo.
Implementations§
source§impl FileLock
impl FileLock
sourcepub fn try_open_rw(path: impl Into<PathBuf>) -> Result<Option<Self>>
pub fn try_open_rw(path: impl Into<PathBuf>) -> Result<Option<Self>>
Attempts to acquire exclusive access to a file, returning the locked version of a file.
This function will create a file at path if it doesn’t already exist
(including intermediate directories), and then it will try to acquire an
exclusive lock on path.
If the lock cannot be immediately acquired, Ok(None) is returned.
The returned file can be accessed to look at the path and also has read/write access to the underlying file.
sourcepub fn open_rw(path: impl Into<PathBuf>) -> Result<Self>
pub fn open_rw(path: impl Into<PathBuf>) -> Result<Self>
Opens exclusive access to a file, returning the locked version of a file.
This function will create a file at path if it doesn’t already exist
(including intermediate directories), and then it will acquire an
exclusive lock on path.
If the lock cannot be acquired, this function will block until it is acquired.
The returned file can be accessed to look at the path and also has read/write access to the underlying file.
sourcepub fn try_open_ro(path: impl Into<PathBuf>) -> Result<Option<Self>>
pub fn try_open_ro(path: impl Into<PathBuf>) -> Result<Option<Self>>
Attempts to acquire shared access to a file, returning the locked version of a file.
This function will fail if path doesn’t already exist, but if it does
then it will acquire a shared lock on path.
If the lock cannot be immediately acquired, Ok(None) is returned.
The returned file can be accessed to look at the path and also has read access to the underlying file. Any writes to the file will return an error.
sourcepub fn open_ro(path: impl Into<PathBuf>) -> Result<Self>
pub fn open_ro(path: impl Into<PathBuf>) -> Result<Self>
Opens shared access to a file, returning the locked version of a file.
This function will fail if path doesn’t already exist, but if it does
then it will acquire a shared lock on path.
If the lock cannot be acquired, this function will block until it is acquired.
The returned file can be accessed to look at the path and also has read access to the underlying file. Any writes to the file will return an error.
Trait Implementations§
source§impl Read for FileLock
impl Read for FileLock
source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read, except that it reads into a slice of buffers. Read moresource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector)1.0.0 · source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf. Read more1.0.0 · source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf. Read more1.6.0 · source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf. Read moresource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)cursor. Read more1.0.0 · source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere Self: Sized,
Read. Read moresource§impl Seek for FileLock
impl Seek for FileLock
source§fn seek(&mut self, to: SeekFrom) -> Result<u64>
fn seek(&mut self, to: SeekFrom) -> Result<u64>
1.55.0 · source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
source§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
seek_stream_len)source§impl Write for FileLock
impl Write for FileLock
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)