pub struct FileLock<FE> { /* private fields */ }
Expand description
A futures-aware read-write lock on a file
Implementations§
source§impl<FE> FileLock<FE>
impl<FE> FileLock<FE>
sourcepub fn new<F>(
cache: Arc<Cache<FE>>,
path: PathBuf,
contents: F,
size: usize
) -> Selfwhere
FE: From<F>,
pub fn new<F>(
cache: Arc<Cache<FE>>,
path: PathBuf,
contents: F,
size: usize
) -> Selfwhere
FE: From<F>,
Create a new FileLock
.
sourcepub fn load<F>(cache: Arc<Cache<FE>>, path: PathBuf) -> Selfwhere
FE: From<F>,
pub fn load<F>(cache: Arc<Cache<FE>>, path: PathBuf) -> Selfwhere
FE: From<F>,
Load a new FileLock
.
sourcepub async fn read<F>(&self) -> Result<FileReadGuard<'_, F>, Error>
pub async fn read<F>(&self) -> Result<FileReadGuard<'_, F>, Error>
Lock this file for reading.
sourcepub fn try_read<F>(&self) -> Result<FileReadGuard<'_, F>, Error>
pub fn try_read<F>(&self) -> Result<FileReadGuard<'_, F>, Error>
Lock this file for reading synchronously if possible, otherwise return an error.
sourcepub async fn read_owned<F>(&self) -> Result<FileReadGuardOwned<FE, F>, Error>
pub async fn read_owned<F>(&self) -> Result<FileReadGuardOwned<FE, F>, Error>
Lock this file for reading.
sourcepub fn try_read_owned<F>(&self) -> Result<FileReadGuardOwned<FE, F>, Error>
pub fn try_read_owned<F>(&self) -> Result<FileReadGuardOwned<FE, F>, Error>
Lock this file for reading synchronously if possible, otherwise return an error.
sourcepub async fn into_read<F>(self) -> Result<FileReadGuardOwned<FE, F>, Error>
pub async fn into_read<F>(self) -> Result<FileReadGuardOwned<FE, F>, Error>
Lock this file for reading, without borrowing.
sourcepub async fn write<F>(&self) -> Result<FileWriteGuard<'_, F>, Error>
pub async fn write<F>(&self) -> Result<FileWriteGuard<'_, F>, Error>
Lock this file for writing.
sourcepub fn try_write<F>(&self) -> Result<FileWriteGuard<'_, F>, Error>
pub fn try_write<F>(&self) -> Result<FileWriteGuard<'_, F>, Error>
Lock this file for writing synchronously if possible, otherwise return an error.
sourcepub async fn write_owned<F>(&self) -> Result<FileWriteGuardOwned<FE, F>, Error>
pub async fn write_owned<F>(&self) -> Result<FileWriteGuardOwned<FE, F>, Error>
Lock this file for writing.
sourcepub fn try_write_owned<F>(&self) -> Result<FileWriteGuardOwned<FE, F>, Error>where
FE: AsType<F>,
pub fn try_write_owned<F>(&self) -> Result<FileWriteGuardOwned<FE, F>, Error>where
FE: AsType<F>,
Lock this file for writing synchronously if possible, otherwise return an error.
sourcepub async fn into_write<F>(self) -> Result<FileWriteGuardOwned<FE, F>, Error>
pub async fn into_write<F>(self) -> Result<FileWriteGuardOwned<FE, F>, Error>
Lock this file for writing, without borrowing.
sourcepub fn try_into_write<F>(self) -> Result<FileWriteGuardOwned<FE, F>, Error>
pub fn try_into_write<F>(self) -> Result<FileWriteGuardOwned<FE, F>, Error>
Lock this file for writing synchronously, if possible, without borrowing.
Trait Implementations§
Auto Trait Implementations§
impl<FE> !RefUnwindSafe for FileLock<FE>
impl<FE> Send for FileLock<FE>
impl<FE> Sync for FileLock<FE>
impl<FE> Unpin for FileLock<FE>
impl<FE> !UnwindSafe for FileLock<FE>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<F> Match for F
impl<F> Match for F
source§fn matches<T>(&self) -> boolwhere
T: TryCastFrom<Self>,
fn matches<T>(&self) -> boolwhere
T: TryCastFrom<Self>,
Returns
true
if self
can be cast into the target type T
.source§impl<F, T> TryCastFrom<F> for Twhere
T: CastFrom<F>,
impl<F, T> TryCastFrom<F> for Twhere
T: CastFrom<F>,
source§fn can_cast_from(_: &F) -> bool
fn can_cast_from(_: &F) -> bool
Test if
value
can be cast into Self
.source§fn opt_cast_from(f: F) -> Option<T>
fn opt_cast_from(f: F) -> Option<T>
Returns
Some(Self)
if the source value can be cast into Self
, otherwise None
.source§impl<F, T> TryCastInto<T> for Fwhere
T: TryCastFrom<F>,
impl<F, T> TryCastInto<T> for Fwhere
T: TryCastFrom<F>,
source§fn can_cast_into(&self) -> bool
fn can_cast_into(&self) -> bool
Test if
self
can be cast into T
.source§fn opt_cast_into(self) -> Option<T>
fn opt_cast_into(self) -> Option<T>
Returns
Some(T)
if self
can be cast into T
, otherwise None
.