pub struct Cache<S>(/* private fields */);Expand description
Implements a caching middleware for reqwest.
Implementations§
Source§impl<S: CacheStorage> Cache<S>
impl<S: CacheStorage> Cache<S>
Sourcepub fn new_with_options(storage: S, options: CacheOptions) -> Self
pub fn new_with_options(storage: S, options: CacheOptions) -> Self
Construct a new caching middleware with the given storage and options.
Sourcepub fn with_revalidation_hook(
self,
hook: impl Fn(&dyn RequestLike, &mut HeaderMap) -> Result<()> + Send + Sync + 'static,
) -> Self
pub fn with_revalidation_hook( self, hook: impl Fn(&dyn RequestLike, &mut HeaderMap) -> Result<()> + Send + Sync + 'static, ) -> Self
Sets the revalidation hook to use.
The hook is provided the original request and a mutable header map containing headers explicitly set for the revalidation request.
For example, a hook may alter the revalidation headers to update an
Authorization header based on the headers used for revalidation.
If the hook returns an error, the error is propagated out as the result of the original request.
Trait Implementations§
Source§impl<S: CacheStorage> Middleware for Cache<S>
impl<S: CacheStorage> Middleware for Cache<S>
Source§fn handle<'a, 'b, 'c, 'd>(
&'a self,
req: Request,
extensions: &'b mut Extensions,
next: Next<'c>,
) -> BoxFuture<'d, Result<Response>>where
Self: 'd,
'a: 'd,
'b: 'd,
'c: 'd,
fn handle<'a, 'b, 'c, 'd>(
&'a self,
req: Request,
extensions: &'b mut Extensions,
next: Next<'c>,
) -> BoxFuture<'d, Result<Response>>where
Self: 'd,
'a: 'd,
'b: 'd,
'c: 'd,
Invoked with a request before sending it. If you want to continue processing the request,
you should explicitly call
next.run(req, extensions). Read moreAuto Trait Implementations§
impl<S> Freeze for Cache<S>where
S: Freeze,
impl<S> !RefUnwindSafe for Cache<S>
impl<S> Send for Cache<S>where
S: Send,
impl<S> Sync for Cache<S>where
S: Sync,
impl<S> Unpin for Cache<S>where
S: Unpin,
impl<S> !UnwindSafe for Cache<S>
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
Mutably borrows from an owned value. Read more