Skip to main content

FileResolver

Trait FileResolver 

Source
pub trait FileResolver:
    Send
    + Sync
    + Debug {
    // Required method
    fn read<'a>(
        &'a self,
        file: &'a File,
        max_bytes: u64,
    ) -> BoxFuture<'a, Result<FileBytes, FileError>>;

    // Provided method
    fn store<'a>(
        &'a self,
        name: &'a str,
        mime_type: Option<&'a str>,
        bytes: Vec<u8>,
    ) -> BoxFuture<'a, Result<File, FileError>> { ... }
}
Expand description

Reads (and optionally stores) file content.

Required Methods§

Source

fn read<'a>( &'a self, file: &'a File, max_bytes: u64, ) -> BoxFuture<'a, Result<FileBytes, FileError>>

Read the whole file, failing with FileError::TooLarge past max_bytes. Return FileError::Unsupported for files this resolver does not handle, so a ChainResolver can try the next one.

Provided Methods§

Source

fn store<'a>( &'a self, name: &'a str, mime_type: Option<&'a str>, bytes: Vec<u8>, ) -> BoxFuture<'a, Result<File, FileError>>

Persist bytes produced by a node and return a File referencing them. Default: unsupported.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§