Trait Io

Source
pub trait Io:
    Send
    + Sync
    + 'static {
    type File: FileExt;
    type TempFile: FileExt;
    type Rng: Rng;

    // Required methods
    fn create_dir_all(&self, path: &Path) -> Result<()>;
    fn open(
        &self,
        create_new: bool,
        read: bool,
        write: bool,
        path: &Path,
    ) -> Result<Self::File>;
    fn tempfile(&self) -> Result<Self::TempFile>;
    fn now(&self) -> DateTime<Utc>;
    fn hard_link(&self, src: &Path, dst: &Path) -> Result<()>;
    fn with_rng<F, R>(&self, f: F) -> R
       where F: FnOnce(&mut Self::Rng) -> R;
    fn remove_file_async(
        &self,
        path: &Path,
    ) -> impl Future<Output = Result<()>> + Send;

    // Provided method
    fn uuid(&self) -> Uuid { ... }
}

Required Associated Types§

Required Methods§

Source

fn create_dir_all(&self, path: &Path) -> Result<()>

Source

fn open( &self, create_new: bool, read: bool, write: bool, path: &Path, ) -> Result<Self::File>

TODO: when adding an async variant make sure all places where async is needed are replaced

Source

fn tempfile(&self) -> Result<Self::TempFile>

Source

fn now(&self) -> DateTime<Utc>

Source

fn with_rng<F, R>(&self, f: F) -> R
where F: FnOnce(&mut Self::Rng) -> R,

Source

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

Provided Methods§

Source

fn uuid(&self) -> Uuid

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<T: Io> Io for Arc<T>

Source§

type File = <T as Io>::File

Source§

type TempFile = <T as Io>::TempFile

Source§

type Rng = <T as Io>::Rng

Source§

fn create_dir_all(&self, path: &Path) -> Result<()>

Source§

fn open( &self, create_new: bool, read: bool, write: bool, path: &Path, ) -> Result<Self::File>

Source§

fn tempfile(&self) -> Result<Self::TempFile>

Source§

fn now(&self) -> DateTime<Utc>

Source§

fn uuid(&self) -> Uuid

Source§

fn with_rng<F, R>(&self, f: F) -> R
where F: FnOnce(&mut Self::Rng) -> R,

Source§

async fn remove_file_async(&self, path: &Path) -> Result<()>

Implementors§