pub struct Node { /* private fields */ }dir only.Expand description
An opened path (aka inode on Unix) as returned by FsDir::open.
This is not necessarily a plain file; it could also be a directory, for example.
The caller can inspect it as desired. If it is a directory, the caller might pass the result of
into_file() to nix::dir::Dir::from. If it is a plain file, the caller might create an
http_serve::Entity with into_file_entity().
Implementations§
Source§impl Node
impl Node
Sourcepub fn into_file_entity<D, E>(
self,
headers: HeaderMap,
) -> Result<ChunkedReadFile<D, E>, Error>
pub fn into_file_entity<D, E>( self, headers: HeaderMap, ) -> Result<ChunkedReadFile<D, E>, Error>
Converts this node (which must represent a plain file) into a ChunkedReadFile.
The caller is expected to supply all headers. The function add_encoding_headers
may be useful.
Sourcepub fn encoding(&self) -> Option<&'static str>
pub fn encoding(&self) -> Option<&'static str>
Returns the encoding this file is assumed to have applied to the caller’s request.
E.g., if automatic gzip compression is enabled and index.html.gz was found when the
caller requested index.html, this will return Some("gzip"). If the caller requests
index.html.gz, this will return None because the gzip encoding is built in to the
caller’s request.
Sourcepub fn encoding_varies(&self) -> bool
pub fn encoding_varies(&self) -> bool
Returns true iff the content varies with the request’s Accept-Encoding header value.
Sourcepub fn add_encoding_headers(&self, hdrs: &mut HeaderMap)
pub fn add_encoding_headers(&self, hdrs: &mut HeaderMap)
Adds Content-Encoding and Vary headers for the encoding to hdrs.
Note if there are other Vary header components known to the caller, this method is
inappropriate.