pub struct Caching { /* private fields */ }Available on crate feature
fs only.Expand description
Controls if caching information should be sent.
The Caching struct contains an Etag which stores a random tag which indentifies a specific file. The Etag gets generated when the struct gets created.
Example
ⓘ
use fire::{get, Request};
use fire::fs::Caching;
use fire::into::IntoResponse;
use std::cell::LazyCell;
const INDEX_CACHE: LazyCell<Caching> = LazyCell::new(|| {
Caching::default()
});
#[get("/")]
fn index(req: &mut Request) -> Response {
let cache = INDEX_CACHE.clone();
if cache.if_none_match(req.header()) {
return cache.into_response()
}
let mut resp = Response::html("<h1>Hello, World!</h1>");
cache.complete_header(&mut resp.header);
resp
}Implementations
sourceimpl Caching
impl Caching
pub fn new(max_age: Duration) -> Self
pub fn default() -> Self
pub fn if_none_match(&self, header: &RequestHeader) -> bool
pub fn complete_header(self, header: &mut ResponseHeader)
Trait Implementations
sourceimpl IntoResponse for Caching
impl IntoResponse for Caching
fn into_response(self) -> Response
impl Eq for Caching
impl StructuralEq for Caching
impl StructuralPartialEq for Caching
Auto Trait Implementations
impl RefUnwindSafe for Caching
impl Send for Caching
impl Sync for Caching
impl Unpin for Caching
impl UnwindSafe for Caching
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.