pub struct MarketMetadata { /* private fields */ }Expand description
The app’s market metadata: the fetched ticker info, the cache toggle, the freshness stamps, and the per-venue in-flight set. Freshness is tracked per venue, so one failed venue can never be masked by successful fetches of another, and a missing stamp counts as stale (which drives a fetch).
Implementations§
Source§impl MarketMetadata
impl MarketMetadata
Sourcepub fn with_cache_enabled(cache_enabled: bool) -> Self
pub fn with_cache_enabled(cache_enabled: bool) -> Self
Create with the cache toggle from saved settings, loading the disk cache when it is enabled. Stale entries are still served and refreshed in the background instead of blocking startup.
pub fn set_cache_enabled(&mut self, enabled: bool)
pub fn cache_enabled(&self) -> bool
pub fn tickers(&self) -> &FxHashMap<Ticker, Option<TickerInfo>>
Sourcepub fn usable_entries_for(
&self,
venue: Venue,
) -> HashMap<Ticker, Option<TickerInfo>>
pub fn usable_entries_for( &self, venue: Venue, ) -> HashMap<Ticker, Option<TickerInfo>>
Entries available for a venue — session-fetched or cache-seeded — regardless of the cache toggle. Used for startup cache hits and for deciding whether a failed refresh can degrade gracefully.
Sourcepub fn last_updated_for(&self, venue: Venue) -> Option<DateTime<Utc>>
pub fn last_updated_for(&self, venue: Venue) -> Option<DateTime<Utc>>
The freshness stamp persisted for a venue, if any.
Sourcepub fn latest_update_for(
&self,
venues: &FxHashSet<Venue>,
) -> Option<DateTime<Utc>>
pub fn latest_update_for( &self, venues: &FxHashSet<Venue>, ) -> Option<DateTime<Utc>>
The most recent freshness stamp among the given venues, if any.
Sourcepub fn needs_fetch(&self, venue: Venue) -> bool
pub fn needs_fetch(&self, venue: Venue) -> bool
Whether a venue’s metadata is missing or too old to trust. This is the single rule that decides when a (re)fetch is needed; a missing stamp counts as stale so the venue gets fetched.
Sourcepub fn begin_fetch(&mut self, venue: Venue) -> bool
pub fn begin_fetch(&mut self, venue: Venue) -> bool
Mark a metadata fetch as started for a venue. Returns false if one is
already in flight, so concurrent fetches for the same venue are
impossible by construction.
Sourcepub fn complete_fetch(&mut self, venue: Venue)
pub fn complete_fetch(&mut self, venue: Venue)
Mark a metadata fetch as finished for a venue, whether it succeeded or
failed. The freshness stamp is untouched by failure: a failed refresh
leaves the previous stamp in place, so needs_fetch keeps driving
retries.
pub fn is_in_flight(&self, venue: Venue) -> bool
pub fn any_in_flight(&self) -> bool
Sourcepub fn ingest(
&mut self,
venue: Venue,
entries: &HashMap<Ticker, Option<TickerInfo>>,
source: MetadataSource,
)
pub fn ingest( &mut self, venue: Venue, entries: &HashMap<Ticker, Option<TickerInfo>>, source: MetadataSource, )
Apply a metadata result for a venue, stamping the venue’s freshness.
Single ingest rule: fresh network results always apply; cache seeds apply only when at least as new as the current stamp. A seed landing after a newer result (e.g. a network fetch that already completed) is skipped instead of clobbering it. Empty results never apply, so a degraded fetch can’t renew the freshness window with nothing.
Sourcepub fn save_to_file(&self) -> bool
pub fn save_to_file(&self) -> bool
Merge this snapshot into the on-disk cache and persist it, newest entries winning per venue. Returns whether the data was persisted.
Trait Implementations§
Source§impl Clone for MarketMetadata
impl Clone for MarketMetadata
Source§impl Default for MarketMetadata
impl Default for MarketMetadata
Source§impl<'de> Deserialize<'de> for MarketMetadata
impl<'de> Deserialize<'de> for MarketMetadata
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Auto Trait Implementations§
impl Freeze for MarketMetadata
impl RefUnwindSafe for MarketMetadata
impl Send for MarketMetadata
impl Sync for MarketMetadata
impl Unpin for MarketMetadata
impl UnsafeUnpin for MarketMetadata
impl UnwindSafe for MarketMetadata
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T, C> ComponentsInto<C> for T
impl<T, C> ComponentsInto<C> for T
Source§fn components_into(self) -> C
fn components_into(self) -> C
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.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, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
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 moreSource§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more