tower_http_cache_plus/cache/key/
key.rs1use super::super::weight::*;
2
3use {
4 http::{header::*, uri::*, *},
5 std::{fmt, hash::*},
6};
7
8pub trait CacheKey
14where
15 Self: 'static + Clone + fmt::Display + Eq + Hash + Send + CacheWeight + Sync,
16{
17 fn for_request(method: &Method, uri: &Uri, headers: &HeaderMap) -> Self;
19}
20
21pub trait CacheKeyForRequest<CacheKeyT> {
27 fn cache_key(&self) -> CacheKeyT;
29}
30
31impl<RequestBodyT, CacheKeyT> CacheKeyForRequest<CacheKeyT> for Request<RequestBodyT>
32where
33 CacheKeyT: CacheKey,
34{
35 fn cache_key(&self) -> CacheKeyT {
36 CacheKeyT::for_request(self.method(), self.uri(), self.headers())
37 }
38}