Skip to main content

Backend

Trait Backend 

Source
pub trait Backend:
    Clone
    + Send
    + Sync
    + 'static {
    type File: File<Metadata = Self::Metadata>;
    type Metadata: Metadata;
    type OpenFuture: Future<Output = Result<Self::File>> + Send;
    type MetadataFuture: Future<Output = Result<Self::Metadata>> + Send;

    // Required methods
    fn open(&self, path: PathBuf) -> Self::OpenFuture;
    fn metadata(&self, path: PathBuf) -> Self::MetadataFuture;
}
Available on crate feature fs only.
Expand description

Trait abstracting filesystem operations for ServeDir.

Implement this trait to serve files from non-filesystem sources. The default implementation (TokioBackend) wraps tokio::fs.

Required Associated Types§

Source

type File: File<Metadata = Self::Metadata>

The file type returned by Backend::open.

Source

type Metadata: Metadata

The metadata type returned by Backend::metadata.

Source

type OpenFuture: Future<Output = Result<Self::File>> + Send

Future returned by Backend::open.

Source

type MetadataFuture: Future<Output = Result<Self::Metadata>> + Send

Future returned by Backend::metadata.

Required Methods§

Source

fn open(&self, path: PathBuf) -> Self::OpenFuture

Open a file at the given path.

Source

fn metadata(&self, path: PathBuf) -> Self::MetadataFuture

Retrieve metadata for the given path without opening the file.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§