Struct http_serve::ChunkedReadFile
source · pub struct ChunkedReadFile<D: 'static + Send + Buf + From<Vec<u8>> + From<&'static [u8]>, E: 'static + Send + Into<Box<dyn Error + Send + Sync>> + From<Box<Error>>> { /* private fields */ }
Expand description
A HTTP entity created from a std::fs::File
which reads the file
chunk-by-chunk on a CpuPool
.
Implementations
sourceimpl<D, E> ChunkedReadFile<D, E>where
D: 'static + Send + Buf + From<Vec<u8>> + From<&'static [u8]>,
E: 'static + Send + Into<Box<dyn Error + Send + Sync>> + From<Box<Error>>,
impl<D, E> ChunkedReadFile<D, E>where
D: 'static + Send + Buf + From<Vec<u8>> + From<&'static [u8]>,
E: 'static + Send + Into<Box<dyn Error + Send + Sync>> + From<Box<Error>>,
sourcepub fn new(
file: File,
pool: Option<CpuPool>,
headers: HeaderMap
) -> Result<Self, Error>
pub fn new(
file: File,
pool: Option<CpuPool>,
headers: HeaderMap
) -> Result<Self, Error>
Creates a new ChunkedReadFile.
read(2)
calls will be performed on the supplied pool
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 shouldn’t be
called on the tokio reactor either.
Trait Implementations
sourceimpl<D: Clone + 'static + Send + Buf + From<Vec<u8>> + From<&'static [u8]>, E: Clone + 'static + Send + Into<Box<dyn Error + Send + Sync>> + From<Box<Error>>> Clone for ChunkedReadFile<D, E>
impl<D: Clone + 'static + Send + Buf + From<Vec<u8>> + From<&'static [u8]>, E: Clone + 'static + Send + Into<Box<dyn Error + Send + Sync>> + From<Box<Error>>> Clone for ChunkedReadFile<D, E>
sourcefn clone(&self) -> ChunkedReadFile<D, E>
fn clone(&self) -> ChunkedReadFile<D, E>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl<D, E> Entity for ChunkedReadFile<D, E>where
D: 'static + Send + Buf + From<Vec<u8>> + From<&'static [u8]>,
E: 'static + Send + Into<Box<dyn Error + Send + Sync>> + From<Box<Error>>,
impl<D, E> Entity for ChunkedReadFile<D, E>where
D: 'static + Send + Buf + From<Vec<u8>> + From<&'static [u8]>,
E: 'static + Send + Into<Box<dyn Error + Send + Sync>> + From<Box<Error>>,
type Error = E
sourcefn get_range(
&self,
range: Range<u64>
) -> Box<dyn Stream<Item = Self::Data, Error = Self::Error> + Send>
fn get_range(
&self,
range: Range<u64>
) -> Box<dyn Stream<Item = Self::Data, Error = Self::Error> + Send>
Gets the body bytes indicated by
range
.sourcefn add_headers(&self, h: &mut HeaderMap)
fn add_headers(&self, h: &mut HeaderMap)
Adds entity headers such as
Content-Type
to the supplied Headers
object.
In particular, these headers are the “other representation header fields” described by RFC
7233 section 4.1; they should exclude
Content-Range
, Date
, Cache-Control
, ETag
, Expires
, Content-Location
, and Vary
. Read moresourcefn etag(&self) -> Option<HeaderValue>
fn etag(&self) -> Option<HeaderValue>
Returns an etag for this entity, if available.
Implementations are encouraged to provide a strong etag. RFC 7232 section
2.1 notes that only strong etags
are usable for sub-range retrieval. Read more
sourcefn last_modified(&self) -> Option<SystemTime>
fn last_modified(&self) -> Option<SystemTime>
Returns the last modified time of this entity, if available.
Note that
serve
may serve an earlier Last-Modified:
date than the one returned here if
this time is in the future, as required by RFC 7232 section
2.2.1. Read moreAuto 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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more