pub struct Fetched<T> {
pub data: T,
pub cache_policy: Option<CachePolicy>,
pub meta: Option<Value>,
}core only.Expand description
A fetcher success carrying an optional server-derived cache policy.
Return this from a *_with_policy fetcher to let the server override the
caller’s CachePolicy for the resolved resource (“server wins”):
Fetched::new— no policy override; the resource keeps the caller’s policy.Fetched::with_policy— override the resource’s policy with the server’s.Fetched::with_meta(persistfeature) — attach opaque metadata that flows intoPersistedEntry::metaso it can be rehydrated on a cold start (e.g. an HTTPCacheMetafor cheap304refetches after relaunch).
cache_policy: None (the default) keeps the caller’s per-query policy
unchanged, matching the plain Result<T, E> fetcher behavior exactly.
Fields§
§data: TThe fetched data.
cache_policy: Option<CachePolicy>Server-derived cache policy. None keeps the caller’s policy.
meta: Option<Value>persist only.Opaque metadata carried through to persistence (e.g. HTTP CacheMeta).
None unless set via Fetched::with_meta. Only present under the
persist feature so the ungated core layer stays serde_json-free.
Implementations§
Source§impl<T> Fetched<T>
impl<T> Fetched<T>
Sourcepub fn new(data: T) -> Self
pub fn new(data: T) -> Self
Wrap fetched data with no policy override (keep the caller’s policy).
Equivalent to returning the bare T from a plain Result<T, E> fetcher.
Sourcepub fn with_policy(data: T, policy: CachePolicy) -> Self
pub fn with_policy(data: T, policy: CachePolicy) -> Self
Wrap fetched data and override the resource’s cache policy with the server’s.
Sourcepub fn with_meta(self, meta: JsonValue) -> Self
Available on crate feature persist only.
pub fn with_meta(self, meta: JsonValue) -> Self
persist only.Attach opaque metadata (e.g. a serialized HTTP CacheMeta) to this
fetched value. Requires the persist feature; the metadata flows into
PersistedEntry::meta when the
resource is persisted, enabling cold-start revalidation.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Fetched<T>where
T: Freeze,
impl<T> RefUnwindSafe for Fetched<T>where
T: RefUnwindSafe,
impl<T> Send for Fetched<T>where
T: Send,
impl<T> Sync for Fetched<T>where
T: Sync,
impl<T> Unpin for Fetched<T>where
T: Unpin,
impl<T> UnsafeUnpin for Fetched<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Fetched<T>where
T: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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> ⓘ
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> ⓘ
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