[][src]Struct http_serve::ChunkedReadFile

pub struct ChunkedReadFile<D: 'static + Send + Buf + From<Vec<u8>> + From<&'static [u8]>, E: 'static + Send + Into<Box<dyn StdError + Send + Sync>> + From<Box<dyn StdError + Send + Sync>>> { /* fields omitted */ }

A HTTP entity created from a std::fs::File which reads the file chunk-by-chunk within a tokio::task::block_in_place closure.

Expects to be used from a tokio threadpool.

Implementations

impl<D, E> ChunkedReadFile<D, E> where
    D: 'static + Send + Sync + Buf + From<Vec<u8>> + From<&'static [u8]>,
    E: 'static + Send + Sync + Into<Box<dyn StdError + Send + Sync>> + From<Box<dyn StdError + Send + Sync>>, 
[src]

pub fn new(file: File, headers: HeaderMap) -> Result<Self, Error>[src]

Creates a new ChunkedReadFile.

read(2) calls will be wrapped in tokio::task::block_in_place calls so that they don't block the tokio reactor thread on local disk I/O. Note that File::open and this constructor (specifically, its call to fstat(2)) may also block, so they typically should be wrapped in tokio::task::block_in_place as well.

Trait Implementations

impl<D: Clone + 'static + Send + Buf + From<Vec<u8>> + From<&'static [u8]>, E: Clone + 'static + Send + Into<Box<dyn StdError + Send + Sync>> + From<Box<dyn StdError + Send + Sync>>> Clone for ChunkedReadFile<D, E>[src]

impl<D, E> Entity for ChunkedReadFile<D, E> where
    D: 'static + Send + Sync + Buf + From<Vec<u8>> + From<&'static [u8]>,
    E: 'static + Send + Sync + Into<Box<dyn StdError + Send + Sync>> + From<Box<dyn StdError + Send + Sync>>, 
[src]

type Data = D

The type of a data chunk. Read more

type Error = E

Auto Trait Implementations

impl<D, E> RefUnwindSafe for ChunkedReadFile<D, E> where
    D: RefUnwindSafe,
    E: RefUnwindSafe

impl<D, E> Send for ChunkedReadFile<D, E>

impl<D, E> Sync for ChunkedReadFile<D, E> where
    D: Sync,
    E: Sync

impl<D, E> Unpin for ChunkedReadFile<D, E> where
    D: Unpin,
    E: Unpin

impl<D, E> UnwindSafe for ChunkedReadFile<D, E> where
    D: UnwindSafe,
    E: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Sealed<T> for T where
    T: ?Sized

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.