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§
Sourcetype File: File<Metadata = Self::Metadata>
type File: File<Metadata = Self::Metadata>
The file type returned by Backend::open.
Sourcetype Metadata: Metadata
type Metadata: Metadata
The metadata type returned by Backend::metadata.
Sourcetype OpenFuture: Future<Output = Result<Self::File>> + Send
type OpenFuture: Future<Output = Result<Self::File>> + Send
Future returned by Backend::open.
Sourcetype MetadataFuture: Future<Output = Result<Self::Metadata>> + Send
type MetadataFuture: Future<Output = Result<Self::Metadata>> + Send
Future returned by Backend::metadata.
Required Methods§
Sourcefn open(&self, path: PathBuf) -> Self::OpenFuture
fn open(&self, path: PathBuf) -> Self::OpenFuture
Open a file at the given path.
Sourcefn metadata(&self, path: PathBuf) -> Self::MetadataFuture
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".