Trait UnifiedFs

Source
pub trait UnifiedFs {
    type ErrRes: Display;
    type FileOp;

    // Required methods
    async fn metadata(path: &Path) -> Result<Metadata, Self::ErrRes>;
    async fn open<P: AsRef<Path>>(path: P) -> Result<Self::FileOp>;
    async fn read_to_string(
        file: &mut Self::FileOp,
        buf: &mut String,
    ) -> Result<usize>;
}
Expand description

A trait which unifies the file IO operations.

Required Associated Types§

Source

type ErrRes: Display

Error type for metadata operation.

Source

type FileOp

A file realization struct.

Required Methods§

Source

async fn metadata(path: &Path) -> Result<Metadata, Self::ErrRes>

Get the metadata for the file specified by the argument path.

Source

async fn open<P: AsRef<Path>>(path: P) -> Result<Self::FileOp>

Open the file specified by the argument path for reading only!

Source

async fn read_to_string( file: &mut Self::FileOp, buf: &mut String, ) -> Result<usize>

Reads from the file of typeSelf::FileOp into a String buffer a file content.

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 UnifiedFs for File

Source§

type ErrRes = Error

Source§

type FileOp = File

Source§

async fn metadata(path: &Path) -> Result<Metadata, Self::ErrRes>

Source§

async fn open<P: AsRef<Path>>(path: P) -> Result<Self::FileOp>

Source§

async fn read_to_string( file: &mut Self::FileOp, buf: &mut String, ) -> Result<usize>

Implementors§