Trait FileProvider

Source
pub trait FileProvider {
    // Required method
    fn read_bytes<P: AsRef<Path>>(
        &self,
        path: P,
    ) -> Result<Cow<'_, [u8]>, Error>;

    // Provided method
    fn read_str<P: AsRef<Path>>(&self, path: P) -> Result<Cow<'_, str>, Error> { ... }
}
Expand description

A trait for providing file contents.

Required Methods§

Source

fn read_bytes<P: AsRef<Path>>(&self, path: P) -> Result<Cow<'_, [u8]>, Error>

Reads the contents of the file at the given path as bytes.

§Errors
  • If an error occurs while reading the file.
  • If the file does not exist.

Provided Methods§

Source

fn read_str<P: AsRef<Path>>(&self, path: P) -> Result<Cow<'_, str>, Error>

Reads the contents of the file at the given path.

§Errors
  • If an error occurs while reading the file.
  • If the file does not exist.
  • If the file is not valid UTF-8.

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 FileProvider for VFolder

Source§

fn read_bytes<P: AsRef<Path>>(&self, path: P) -> Result<Cow<'_, [u8]>, Error>

Source§

fn read_str<P: AsRef<Path>>(&self, path: P) -> Result<Cow<'_, str>, Error>

Implementors§