Struct ServeFile

Source
pub struct ServeFile<W, C> {
    pub content_type: Mime,
    pub content_disposition: ContentDisposition,
    /* private fields */
}
Expand description

File service helper

Fields§

§content_type: Mime

File’s MIME type

§content_disposition: ContentDisposition

File’s Content-Disposition

Implementations§

Source§

impl<W: FsTaskSpawner, C: FileServeConfig> ServeFile<W, C>

Source

pub fn open(path: &Path) -> Result<Self>

Opens file to serve.

Source

pub fn from_parts(file_name: &str, file: File, meta: Metadata) -> Self

Creates new instance from already opened file

Source

pub fn from_parts_with_cfg(file_name: &str, file: File, meta: Metadata) -> Self

Creates new instance from already opened file

Source

pub fn etag(&self) -> EntityTag

Creates EntityTag for file

Source

pub fn last_modified(&self) -> Option<HttpDate>

Creates HttpDate instance for file, if possible

Source

pub fn len(&self) -> u64

Returns length of File.

Source

pub fn prepare( self, path: &Path, method: Method, headers: &HeaderMap, out_headers: &mut HeaderMap, ) -> (StatusCode, Body<W, C>)

Prepares file for service

Trait Implementations§

Source§

impl<W, C> Into<File> for ServeFile<W, C>

Source§

fn into(self) -> File

Converts this type into the (usually inferred) input type.

Auto Trait Implementations§

§

impl<W, C> Freeze for ServeFile<W, C>

§

impl<W, C> RefUnwindSafe for ServeFile<W, C>

§

impl<W, C> Send for ServeFile<W, C>
where W: Send, C: Send,

§

impl<W, C> Sync for ServeFile<W, C>
where W: Sync, C: Sync,

§

impl<W, C> Unpin for ServeFile<W, C>
where W: Unpin, C: Unpin,

§

impl<W, C> UnwindSafe for ServeFile<W, C>
where W: UnwindSafe, C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.