pub struct Settings { /* private fields */ }
Expand description
The rules for handling and caching a request/response.
Implementations§
source§impl Settings
impl Settings
sourcepub fn empty() -> Self
pub fn empty() -> Self
Returns an empty set of rules. Will not cache any variants, except compressed.
sourcepub fn add_rule(
self,
request_header: &'static str,
transformation: impl Fn(&str) -> Cow<'static, str> + Send + Sync + 'static,
default: &'static str,
) -> Self
pub fn add_rule( self, request_header: &'static str, transformation: impl Fn(&str) -> Cow<'static, str> + Send + Sync + 'static, default: &'static str, ) -> Self
Add a custom rule.
The request_header
is used when outputting the vary
header
and for the internal cache.
transformation
takes request_header
and (hopefully, for performance)
narrows the variants down to a finite number.
Prefer to return a limited set of strings from the transformation to minimize cache size. If you generate
String
s, limit the amount of different strings.
If you have a large set or infinitely many variants outputted by transformation
,
the cache will suffer. Consider disabling the cache for the files affected by this rule
to improve performance.
§Panics
Will panic if the request_header
contains invalid bytes.
All of the bytes must satisfy b >= 32 && b < 127 || b == b'\t'
where b is a byte.
See utils::is_valid_header_value_byte
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Settings
impl !RefUnwindSafe for Settings
impl Send for Settings
impl Sync for Settings
impl Unpin for Settings
impl !UnwindSafe for Settings
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
)