pub struct ResponseCacheEntry {
pub body: String,
pub headers: HashMap<String, String>,
pub status_code: u16,
pub etag: String,
pub last_modified: u64,
pub content_type: String,
pub compressed: bool,
pub created_at: u64,
pub expires_at: Option<u64>,
}Expand description
HTTP response cache entry with metadata
Fields§
§body: StringThe cached response body
headers: HashMap<String, String>HTTP headers to include in cached response
status_code: u16Status code of the cached response
etag: StringETag for the cached response
last_modified: u64Last modified timestamp
content_type: StringContent type of the response
compressed: boolWhether the response was compressed
created_at: u64Cache creation timestamp
expires_at: Option<u64>Cache expiration timestamp (if any)
Implementations§
Source§impl ResponseCacheEntry
impl ResponseCacheEntry
Sourcepub fn new(
body: String,
status_code: u16,
content_type: String,
headers: HashMap<String, String>,
ttl: Option<Duration>,
) -> Self
pub fn new( body: String, status_code: u16, content_type: String, headers: HashMap<String, String>, ttl: Option<Duration>, ) -> Self
Create new response cache entry
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if this cache entry is expired
Sourcepub fn to_response(&self) -> Response
pub fn to_response(&self) -> Response
Convert to HTTP Response
Trait Implementations§
Source§impl Clone for ResponseCacheEntry
impl Clone for ResponseCacheEntry
Auto Trait Implementations§
impl Freeze for ResponseCacheEntry
impl RefUnwindSafe for ResponseCacheEntry
impl Send for ResponseCacheEntry
impl Sync for ResponseCacheEntry
impl Unpin for ResponseCacheEntry
impl UnsafeUnpin for ResponseCacheEntry
impl UnwindSafe for ResponseCacheEntry
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more