Struct hyper_staticfile::util::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§
source§impl 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§
source§impl Clone for FileResponseBuilder
impl Clone for FileResponseBuilder
source§fn clone(&self) -> FileResponseBuilder
fn clone(&self) -> FileResponseBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for FileResponseBuilder
impl Debug for FileResponseBuilder
source§impl Default for FileResponseBuilder
impl Default for FileResponseBuilder
source§fn default() -> FileResponseBuilder
fn default() -> FileResponseBuilder
Auto Trait Implementations§
impl Freeze for FileResponseBuilder
impl RefUnwindSafe for FileResponseBuilder
impl Send for FileResponseBuilder
impl Sync for FileResponseBuilder
impl Unpin for FileResponseBuilder
impl UnwindSafe for FileResponseBuilder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)