pub struct Options(/* private fields */);
Expand description

A bitset representing configurable options for the StaticFiles handler.

The valid options are:

Options structures can be ord together to select two or more options. For instance, to request that both dot files and index pages be returned, use Options::DotFiles | Options::Index.

Implementations§

source§

impl Options

source

pub const None: Options = _

Options representing the empty set. No dotfiles or index pages are rendered. This is different than Options::default(), which enables Index.

source

pub const Index: Options = _

Options enabling responding to requests for a directory with the index.html file in that directory, if it exists. When this is enabled, the StaticFiles handler will respond to requests for a directory /foo with the file ${root}/foo/index.html if it exists. This is enabled by default.

source

pub const DotFiles: Options = _

Options enabling returning dot files. When this is enabled, the StaticFiles handler will respond to requests for files or directories beginning with .. This is not enabled by default.

source

pub const NormalizeDirs: Options = _

Options that normalizes directory requests by redirecting requests to directory paths without a trailing slash to ones with a trailing slash.

When enabled, the StaticFiles handler will respond to requests for a directory without a trailing / with a permanent redirect (308) to the same path with a trailing /. This ensures relative URLs within any document served for that directory will be interpreted relative to that directory, rather than its parent. This is not enabled by default.

source

pub fn contains(self, other: Options) -> bool

Returns true if self is a superset of other. In other words, returns true if all of the options in other are also in self.

§Example
use rocket_contrib::serve::Options;

let index_request = Options::Index | Options::DotFiles;
assert!(index_request.contains(Options::Index));
assert!(index_request.contains(Options::DotFiles));

let index_only = Options::Index;
assert!(index_only.contains(Options::Index));
assert!(!index_only.contains(Options::DotFiles));

let dot_only = Options::DotFiles;
assert!(dot_only.contains(Options::DotFiles));
assert!(!dot_only.contains(Options::Index));

Trait Implementations§

source§

impl BitOr for Options

§

type Output = Options

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: Self) -> Self

Performs the | operation. Read more
source§

impl Clone for Options

source§

fn clone(&self) -> Options

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Options

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Options

The default set of options: Options::Index.

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Copy for Options

Auto Trait Implementations§

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, I> AsResult<T, I> for T
where I: Input,

source§

fn as_result(self) -> Result<T, ParseErr<I>>

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.

§

impl<T> IntoCollection<T> for T

§

fn into_collection<A>(self) -> SmallVec<A>
where A: Array<Item = T>,

Converts self into a collection.
§

fn mapped<U, F, A>(self, f: F) -> SmallVec<A>
where F: FnMut(T) -> U, A: Array<Item = U>,

source§

impl<T> IntoSql for T

source§

fn into_sql<T>(self) -> Self::Expression
where Self: AsExpression<T> + Sized,

Convert self to an expression for Diesel’s query builder. Read more
source§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression

Convert &self to an expression for Diesel’s query builder. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.
source§

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

§

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

source§

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

source§

impl<T> Typeable for T
where T: Any,

source§

fn get_type(&self) -> TypeId

Get the TypeId of this object.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V