pub struct CachedResource {
request_headers: Arc<Mutex<SerializeableHeaderMap>>,
body: Arc<Mutex<ResponseBody>>,
aborted: Arc<AtomicBool>,
awaiting_body: Arc<Mutex<Vec<UnboundedSender<Data>>>>,
metadata: CachedMetadata,
location_url: Option<Result<ServoUrl, String>>,
status: HttpStatus,
url_list: Vec<ServoUrl>,
expires: ApproxDuration,
stale_while_revalidate: ApproxDuration,
revalidating: Arc<AtomicBool>,
last_validated: SystemTime,
}Expand description
A complete cached resource.
Fields§
§request_headers: Arc<Mutex<SerializeableHeaderMap>>§body: Arc<Mutex<ResponseBody>>§aborted: Arc<AtomicBool>§awaiting_body: Arc<Mutex<Vec<UnboundedSender<Data>>>>§metadata: CachedMetadata§location_url: Option<Result<ServoUrl, String>>§status: HttpStatus§url_list: Vec<ServoUrl>§expires: ApproxDuration§stale_while_revalidate: ApproxDuration§revalidating: Arc<AtomicBool>§last_validated: SystemTimeImplementations§
Source§impl CachedResource
impl CachedResource
pub(crate) fn is_done(&self) -> bool
Sourcefn can_be_used_to_answer(&self, request: &Request) -> bool
fn can_be_used_to_answer(&self, request: &Request) -> bool
Whether this CachedResource can be used to answer the given Request. This
is true if:
- The resource is not for an aborted load.
- The fields named in the
Varyheader match those of theRequest. - It is not a partial (206) response or the request has a
Rangeheader. When the request has aRangeheader the caller is expected to decide which part of the resource to use.
Sourcefn vary_header_matches(&self, request_headers: &HeaderMap) -> bool
fn vary_header_matches(&self, request_headers: &HeaderMap) -> bool
Whether the given request headers match the cached resource’s request headers
on every field named in the Vary header according to the rules specified in
https://httpwg.org/specs/rfc9111.html#caching.negotiated.responses.
When a cache receives a request that can be satisfied by a stored response and that stored response contains a Vary header field (Section 12.5.5 of [HTTP]), the cache MUST NOT use that stored response without revalidation unless all the presented request header fields nominated by that Vary field value match those fields in the original request (i.e., the request that caused the cached response to be stored).
Trait Implementations§
Source§impl Clone for CachedResource
impl Clone for CachedResource
Source§fn clone(&self) -> CachedResource
fn clone(&self) -> CachedResource
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CachedResource
impl Debug for CachedResource
Source§impl<'de> Deserialize<'de> for CachedResource
impl<'de> Deserialize<'de> for CachedResource
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl MallocSizeOf for CachedResource
impl MallocSizeOf for CachedResource
Source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Measure the heap usage of all descendant heap-allocated structures, but
not the space taken up by the value itself.
Auto Trait Implementations§
impl !RefUnwindSafe for CachedResource
impl !UnwindSafe for CachedResource
impl Freeze for CachedResource
impl Send for CachedResource
impl Sync for CachedResource
impl Unpin for CachedResource
impl UnsafeUnpin for CachedResource
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> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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 moreSource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
Source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
Source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
Source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert