pub struct FileOptions { /* private fields */ }
Expand description

Options to pass to file or dir handlers. Allows overriding default behaviour for compression, cache control headers, etc.

FileOptions implements From for String and PathBuf (and related reference types) - so that a path can be passed to router builder methods if only default options are required.

For overridding default options, FileOptions provides builder methods. The default values and use of the builder methods are shown in the example below.


let default_options = FileOptions::from("my_static_path");
let from_builder = FileOptions::new("my_static_path")
    .with_cache_control("public")
    .with_gzip(false)
    .with_brotli(false)
    .build();

assert_eq!(default_options, from_builder);

Implementations

Create a new FileOptions with default values.

Sets the “cache_control” header in static file responses to the given value.

If true, given a request for FILE, serves FILE.gz if it exists in the static directory and if the accept-encoding header is set to allow gzipped content (defaults to false).

If true, given a request for FILE, serves FILE.br if it exists in the static directory and if the accept-encoding header is set to allow brotli content (defaults to false).

Clones self to return an owned value for passing to a handler.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

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)

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.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more