Node

Struct Node 

Source
pub struct Node { /* private fields */ }
Available on crate feature 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

Source

pub fn into_file(self) -> File

Converts this node to a std::fs::File.

Source

pub fn into_file_entity<D, E>( self, headers: HeaderMap, ) -> Result<ChunkedReadFile<D, E>, Error>
where D: 'static + Send + Sync + Buf + From<Vec<u8>> + From<&'static [u8]>, E: 'static + Send + Sync + Into<Box<dyn Error + Send + Sync>> + From<Box<dyn Error + Send + Sync>>,

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.

Source

pub fn metadata(&self) -> &Metadata

Returns the (already fetched) metadata for this node.

Source

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.

Source

pub fn encoding_varies(&self) -> bool

Returns true iff the content varies with the request’s Accept-Encoding header value.

Source

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.

Auto Trait Implementations§

§

impl Freeze for Node

§

impl RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnwindSafe for Node

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.