Trait OpenOptionsExt

Source
pub trait OpenOptionsExt {
    // Required methods
    fn try_open_shared(&self, path: &Path) -> Result<Option<LockedFile>>;
    fn open_shared(
        &self,
        path: &Path,
    ) -> impl Future<Output = Result<LockedFile>> + Send;
    fn try_open_exclusive(&self, path: &Path) -> Result<Option<LockedFile>>;
    fn open_exclusive(
        &self,
        path: &Path,
    ) -> impl Future<Output = Result<LockedFile>> + Send;
}
Expand description

An extension trait for OpenOptions.

When the file_lock Rust feature stabilizes, this implementation will be removed.

Required Methods§

Source

fn try_open_shared(&self, path: &Path) -> Result<Option<LockedFile>>

Attempts to open a file with a shared lock.

Returns the locked file upon success.

If the lock cannot be immediately acquired, Ok(None) is returned.

Source

fn open_shared( &self, path: &Path, ) -> impl Future<Output = Result<LockedFile>> + Send

Attempts to open a file with a shared lock.

Returns the locked file upon success.

Source

fn try_open_exclusive(&self, path: &Path) -> Result<Option<LockedFile>>

Attempts to open a file with an exclusive lock.

Returns the locked file upon success.

If the lock cannot be immediately acquired, Ok(None) is returned.

Source

fn open_exclusive( &self, path: &Path, ) -> impl Future<Output = Result<LockedFile>> + Send

Attempts to open a file with an exclusive lock.

Returns the locked file upon success.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl OpenOptionsExt for OpenOptions

Implementors§