Struct rocket_contrib::serve::Options[][src]

pub struct Options(_);
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

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

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.

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.

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.

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

The resulting type after applying the | operator.

Performs the | operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The default set of options: Options::Index.

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Converts self into a collection.

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Get the TypeId of this object.