pub struct Outcome<T> {
pub snapshot: T,
pub stale: bool,
pub last_error: Option<(u16, String)>,
pub cache_age: Option<Duration>,
}Expand description
A snapshot with its provenance.
Fields§
§snapshot: T§stale: boolThe payload is past its TTL — shown, but marked.
last_error: Option<(u16, String)>The failure recorded by the most recent unsuccessful refresh, redacted
by Cache::write_last_error. None means the last refresh worked.
cache_age: Option<Duration>How long ago the payload was written. None when unknown.
Implementations§
Source§impl<T> Outcome<T>
impl<T> Outcome<T>
Sourcepub fn fresh(snapshot: T) -> Self
pub fn fresh(snapshot: T) -> Self
Straight off the wire: fresh, no recorded error, zero age.
Note the deliberate asymmetry with Outcome::cached — a successful
fetch clears last_error rather than reading it back, because the
error it would read is the one this call just superseded.
Sourcepub fn cached(snapshot: T, cache: &Cache, stale: bool) -> Self
pub fn cached(snapshot: T, cache: &Cache, stale: bool) -> Self
Parsed back out of the cache. The recorded error and the payload’s age come from the cache, so a warm-cache render still shows why the last refresh failed.
Sourcepub fn map<U>(self, f: impl FnOnce(T) -> U) -> Outcome<U>
pub fn map<U>(self, f: impl FnOnce(T) -> U) -> Outcome<U>
Re-type the snapshot, keeping the provenance. This is how a vendor’s
own outcome becomes a crate::vendor::VendorOutcome.
Trait Implementations§
Source§impl From<Outcome<AnthropicApiSnapshot>> for VendorOutcome
impl From<Outcome<AnthropicApiSnapshot>> for VendorOutcome
Source§fn from(o: FetchOutcome) -> Self
fn from(o: FetchOutcome) -> Self
Source§impl From<Outcome<AntigravitySnapshot>> for VendorOutcome
impl From<Outcome<AntigravitySnapshot>> for VendorOutcome
Source§fn from(o: FetchOutcome) -> Self
fn from(o: FetchOutcome) -> Self
Source§impl From<Outcome<CursorSnapshot>> for VendorOutcome
impl From<Outcome<CursorSnapshot>> for VendorOutcome
Source§fn from(o: FetchOutcome) -> Self
fn from(o: FetchOutcome) -> Self
Source§impl From<Outcome<CustomSnapshot>> for VendorOutcome
impl From<Outcome<CustomSnapshot>> for VendorOutcome
Source§fn from(o: FetchOutcome) -> Self
fn from(o: FetchOutcome) -> Self
Source§impl From<Outcome<DeepseekSnapshot>> for VendorOutcome
impl From<Outcome<DeepseekSnapshot>> for VendorOutcome
Source§fn from(o: FetchOutcome) -> Self
fn from(o: FetchOutcome) -> Self
Source§impl From<Outcome<GrokSnapshot>> for VendorOutcome
impl From<Outcome<GrokSnapshot>> for VendorOutcome
Source§fn from(o: FetchOutcome) -> Self
fn from(o: FetchOutcome) -> Self
Source§impl From<Outcome<GrokbotSnapshot>> for VendorOutcome
impl From<Outcome<GrokbotSnapshot>> for VendorOutcome
Source§fn from(o: FetchOutcome) -> Self
fn from(o: FetchOutcome) -> Self
Source§impl From<Outcome<KiloSnapshot>> for VendorOutcome
impl From<Outcome<KiloSnapshot>> for VendorOutcome
Source§fn from(o: FetchOutcome) -> Self
fn from(o: FetchOutcome) -> Self
Source§impl From<Outcome<KimiSnapshot>> for VendorOutcome
impl From<Outcome<KimiSnapshot>> for VendorOutcome
Source§fn from(o: FetchOutcome) -> Self
fn from(o: FetchOutcome) -> Self
Source§impl From<Outcome<KiroSnapshot>> for VendorOutcome
impl From<Outcome<KiroSnapshot>> for VendorOutcome
Source§fn from(o: FetchOutcome) -> Self
fn from(o: FetchOutcome) -> Self
Source§impl From<Outcome<MinimaxSnapshot>> for VendorOutcome
impl From<Outcome<MinimaxSnapshot>> for VendorOutcome
Source§fn from(o: FetchOutcome) -> Self
fn from(o: FetchOutcome) -> Self
Source§impl From<Outcome<ModelStudioSnapshot>> for VendorOutcome
impl From<Outcome<ModelStudioSnapshot>> for VendorOutcome
Source§fn from(o: FetchOutcome) -> Self
fn from(o: FetchOutcome) -> Self
Source§impl From<Outcome<MoonshotSnapshot>> for VendorOutcome
impl From<Outcome<MoonshotSnapshot>> for VendorOutcome
Source§fn from(o: FetchOutcome) -> Self
fn from(o: FetchOutcome) -> Self
Source§impl From<Outcome<NovitaSnapshot>> for VendorOutcome
impl From<Outcome<NovitaSnapshot>> for VendorOutcome
Source§fn from(o: FetchOutcome) -> Self
fn from(o: FetchOutcome) -> Self
Source§impl From<Outcome<OllamaSnapshot>> for VendorOutcome
impl From<Outcome<OllamaSnapshot>> for VendorOutcome
Source§fn from(o: FetchOutcome) -> Self
fn from(o: FetchOutcome) -> Self
Source§impl From<Outcome<OpenAiSnapshot>> for VendorOutcome
impl From<Outcome<OpenAiSnapshot>> for VendorOutcome
Source§fn from(o: FetchOutcome) -> Self
fn from(o: FetchOutcome) -> Self
Source§impl From<Outcome<OpenRouterSnapshot>> for VendorOutcome
impl From<Outcome<OpenRouterSnapshot>> for VendorOutcome
Source§fn from(o: FetchOutcome) -> Self
fn from(o: FetchOutcome) -> Self
Source§impl From<Outcome<OrcaRouterSnapshot>> for VendorOutcome
impl From<Outcome<OrcaRouterSnapshot>> for VendorOutcome
Source§fn from(o: FetchOutcome) -> Self
fn from(o: FetchOutcome) -> Self
Source§impl From<Outcome<Snapshot>> for VendorOutcome
impl From<Outcome<Snapshot>> for VendorOutcome
Source§fn from(outcome: FetchOutcome) -> Self
fn from(outcome: FetchOutcome) -> Self
Source§impl From<Outcome<Snapshot>> for VendorOutcome
impl From<Outcome<Snapshot>> for VendorOutcome
Source§fn from(outcome: FetchOutcome) -> Self
fn from(outcome: FetchOutcome) -> Self
Source§impl From<Outcome<SuperGrokSnapshot>> for VendorOutcome
impl From<Outcome<SuperGrokSnapshot>> for VendorOutcome
Source§fn from(o: FetchOutcome) -> Self
fn from(o: FetchOutcome) -> Self
Source§impl From<Outcome<Usage>> for VendorOutcome
impl From<Outcome<Usage>> for VendorOutcome
Source§fn from(outcome: FetchOutcome) -> Self
fn from(outcome: FetchOutcome) -> Self
Source§impl From<Outcome<ZaiSnapshot>> for VendorOutcome
impl From<Outcome<ZaiSnapshot>> for VendorOutcome
Source§fn from(o: FetchOutcome) -> Self
fn from(o: FetchOutcome) -> Self
Auto Trait Implementations§
impl<T> Freeze for Outcome<T>where
T: Freeze,
impl<T> RefUnwindSafe for Outcome<T>where
T: RefUnwindSafe,
impl<T> Send for Outcome<T>where
T: Send,
impl<T> Sync for Outcome<T>where
T: Sync,
impl<T> Unpin for Outcome<T>where
T: Unpin,
impl<T> UnsafeUnpin for Outcome<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Outcome<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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