Struct rocket_contrib::serve::Options
source · pub struct Options(/* private fields */);
Expand description
A bitset representing configurable options for the StaticFiles
handler.
The valid options are:
Options::None
- Return only present, visible files.Options::DotFiles
- In addition to visible files, return dotfiles.Options::Index
- Renderindex.html
pages for directory requests.Options::NormalizeDirs
- Redirect directories without a trailing slash to ones with a trailing slash.
Options
structures can be or
d 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
impl Options
sourcepub const None: Options = _
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
.
sourcepub const Index: Options = _
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.
sourcepub const DotFiles: Options = _
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.
sourcepub const NormalizeDirs: Options = _
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.
sourcepub fn contains(self, other: Options) -> bool
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§
impl Copy for Options
Auto Trait Implementations§
impl Freeze for Options
impl RefUnwindSafe for Options
impl Send for Options
impl Sync for Options
impl Unpin for Options
impl UnwindSafe for Options
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> IntoCollection<T> for T
impl<T> IntoCollection<T> for T
source§impl<T> IntoSql for T
impl<T> IntoSql for T
source§fn into_sql<T>(self) -> Self::Expressionwhere
Self: Sized + AsExpression<T>,
fn into_sql<T>(self) -> Self::Expressionwhere
Self: Sized + AsExpression<T>,
self
to an expression for Diesel’s query builder. Read moresource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
&'a Self: AsExpression<T>,
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
&'a Self: AsExpression<T>,
&self
to an expression for Diesel’s query builder. Read more