Skip to main content

StaticConnExt

Trait StaticConnExt 

Source
pub trait StaticConnExt: Send {
    // Required methods
    fn send_path<A: AsRef<Path> + Send>(
        self,
        path: A,
    ) -> impl Future<Output = Conn> + Send;
    fn send_file(self, file: File) -> impl Future<Output = Conn> + Send;
    fn send_file_with_options(
        self,
        file: File,
        options: &StaticOptions,
    ) -> impl Future<Output = Conn> + Send;
    fn send_path_with_options<A: AsRef<Path> + Send>(
        self,
        path: A,
        options: &StaticOptions,
    ) -> impl Future<Output = Conn> + Send;
    fn with_mime_from_path(self, path: impl AsRef<Path>) -> Self;
}
Expand description

conn extension trait to facilitate sending individual files and paths

Required Methods§

Source

fn send_path<A: AsRef<Path> + Send>( self, path: A, ) -> impl Future<Output = Conn> + Send

Send the file at the provided path. Will send a 404 if the file cannot be resolved or if it is a directory.

Source

fn send_file(self, file: File) -> impl Future<Output = Conn> + Send

Send the file at the provided path. Will send a 404 if the file cannot be resolved or if it is a directory.

Source

fn send_file_with_options( self, file: File, options: &StaticOptions, ) -> impl Future<Output = Conn> + Send

Send the file at the provided path. Will send a 404 if the file cannot be resolved or if it is a directory.

Source

fn send_path_with_options<A: AsRef<Path> + Send>( self, path: A, options: &StaticOptions, ) -> impl Future<Output = Conn> + Send

Send the file at the provided path. Will send a 404 if the file cannot be resolved or if it is a directory.

Source

fn with_mime_from_path(self, path: impl AsRef<Path>) -> Self

Guess the mime type for this fs path using mime_guess and set the content-type header

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 StaticConnExt for Conn

Source§

async fn send_path<A: AsRef<Path> + Send>(self, path: A) -> Self

Source§

async fn send_file(self, file: File) -> Self

Source§

async fn send_path_with_options<A: AsRef<Path> + Send>( self, path: A, options: &StaticOptions, ) -> Self

Source§

async fn send_file_with_options( self, file: File, options: &StaticOptions, ) -> Self

Source§

fn with_mime_from_path(self, path: impl AsRef<Path>) -> Self

Implementors§