Struct hyper_staticfile::FileResponseBuilder
source · [−]pub struct FileResponseBuilder {
pub cache_headers: Option<u32>,
pub is_head: bool,
pub if_modified_since: Option<SystemTime>,
pub range: Option<String>,
pub if_range: Option<String>,
}
Expand description
Utility to build responses for serving a tokio::fs::File
.
This struct allows direct access to its fields, but these fields are typically initialized by the accessors, using the builder pattern. The fields are basically a bunch of settings that determine the response details.
Fields
cache_headers: Option<u32>
Whether to send cache headers, and what lifespan to indicate.
is_head: bool
Whether this is a HEAD
request, with no response body.
if_modified_since: Option<SystemTime>
The parsed value of the If-Modified-Since
request header.
range: Option<String>
The file ranges to read, if any, otherwise we read from the beginning.
if_range: Option<String>
The unparsed value of the If-Range
request header. May match etag or last-modified.
Implementations
sourceimpl FileResponseBuilder
impl FileResponseBuilder
sourcepub fn request<B>(&mut self, req: &Request<B>) -> &mut Self
pub fn request<B>(&mut self, req: &Request<B>) -> &mut Self
Apply parameters based on a request.
sourcepub fn request_parts(
&mut self,
method: &Method,
headers: &HeaderMap
) -> &mut Self
pub fn request_parts(
&mut self,
method: &Method,
headers: &HeaderMap
) -> &mut Self
Apply parameters based on request parts.
sourcepub fn request_method(&mut self, method: &Method) -> &mut Self
pub fn request_method(&mut self, method: &Method) -> &mut Self
Apply parameters based on a request method.
sourcepub fn request_headers(&mut self, headers: &HeaderMap) -> &mut Self
pub fn request_headers(&mut self, headers: &HeaderMap) -> &mut Self
Apply parameters based on request headers.
sourcepub fn cache_headers(&mut self, value: Option<u32>) -> &mut Self
pub fn cache_headers(&mut self, value: Option<u32>) -> &mut Self
Add cache headers to responses for the given lifespan.
sourcepub fn is_head(&mut self, value: bool) -> &mut Self
pub fn is_head(&mut self, value: bool) -> &mut Self
Set whether this is a HEAD
request, with no response body.
sourcepub fn if_modified_since(&mut self, value: Option<SystemTime>) -> &mut Self
pub fn if_modified_since(&mut self, value: Option<SystemTime>) -> &mut Self
Build responses for the given If-Modified-Since
date-time.
sourcepub fn if_modified_since_header(
&mut self,
value: Option<&HeaderValue>
) -> &mut Self
pub fn if_modified_since_header(
&mut self,
value: Option<&HeaderValue>
) -> &mut Self
Build responses for the given If-Modified-Since
request header value.
sourcepub fn if_range(&mut self, value: Option<&HeaderValue>) -> &mut Self
pub fn if_range(&mut self, value: Option<&HeaderValue>) -> &mut Self
Build responses for the given If-Range
request header value.
sourcepub fn range_header(&mut self, value: Option<&HeaderValue>) -> &mut Self
pub fn range_header(&mut self, value: Option<&HeaderValue>) -> &mut Self
Build responses for the given Range
request header value.
Trait Implementations
sourceimpl Clone for FileResponseBuilder
impl Clone for FileResponseBuilder
sourcefn clone(&self) -> FileResponseBuilder
fn clone(&self) -> FileResponseBuilder
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 more
sourceimpl Debug for FileResponseBuilder
impl Debug for FileResponseBuilder
sourceimpl Default for FileResponseBuilder
impl Default for FileResponseBuilder
sourcefn default() -> FileResponseBuilder
fn default() -> FileResponseBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for FileResponseBuilder
impl Send for FileResponseBuilder
impl Sync for FileResponseBuilder
impl Unpin for FileResponseBuilder
impl UnwindSafe for FileResponseBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more