Struct file_guard::FileGuard
source · pub struct FileGuard<T: Deref<Target = File>> { /* private fields */ }
Expand description
An RAII implementation of a “scoped lock” of a file. When this structure is dropped (falls out of scope), the lock will be unlocked.
This structure is created by the lock()
, try_lock()
, and
lock_any()
functions.
Implementations§
source§impl<T> FileGuard<T>
impl<T> FileGuard<T>
sourcepub fn is_exclusive(&self) -> bool
pub fn is_exclusive(&self) -> bool
sourcepub fn downgrade(&mut self) -> Result<()>
pub fn downgrade(&mut self) -> Result<()>
Safely exchanges an Exclusive
Lock
for a Shared
one.
If the currently held lock is already Shared
, no change is made and
the method succeeds. This exchange safely ensures no lock is released
during operation. That is, no waiting Exclusive
lock attempts may
obtain the lock during the downgrade. Other Shared
locks waiting
will be granted a lock as a result, however.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for FileGuard<T>where
T: Freeze,
impl<T> RefUnwindSafe for FileGuard<T>where
T: RefUnwindSafe,
impl<T> Send for FileGuard<T>where
T: Send,
impl<T> Sync for FileGuard<T>where
T: Sync,
impl<T> Unpin for FileGuard<T>where
T: Unpin,
impl<T> UnwindSafe for FileGuard<T>where
T: UnwindSafe,
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