pub struct PriceHistoryState { /* private fields */ }Expand description
Represents the current state of price history data in the database.
Tracks the time range of available price data, identifies gaps in the data, and determines what additional data needs to be fetched to achieve complete synchronization within a specified reach period.
Implementations§
Source§impl PriceHistoryState
impl PriceHistoryState
Sourcepub async fn evaluate(db: &Database) -> Result<Self, SyncPriceHistoryError>
pub async fn evaluate(db: &Database) -> Result<Self, SyncPriceHistoryError>
Evaluates the current price history state from the database.
Analyzes the database to determine data bounds and gaps without imposing a reach time limit.
Sourcepub fn bounds(&self) -> Option<(DateTime<Utc>, DateTime<Utc>)>
pub fn bounds(&self) -> Option<(DateTime<Utc>, DateTime<Utc>)>
Returns the time bounds of the available price history data.
Returns None if the database is empty, otherwise returns a tuple of
(earliest_time, latest_time).
Sourcepub fn gaps(&self) -> &Vec<(DateTime<Utc>, DateTime<Utc>)>
pub fn gaps(&self) -> &Vec<(DateTime<Utc>, DateTime<Utc>)>
Returns the list of time gaps in the price history data.
Each gap is represented as a tuple of (from_time, to_time).
Sourcepub fn bound_start(&self) -> Option<DateTime<Utc>>
pub fn bound_start(&self) -> Option<DateTime<Utc>>
Returns the start time of the price history bounds.
Sourcepub fn bound_end(&self) -> Option<DateTime<Utc>>
pub fn bound_end(&self) -> Option<DateTime<Utc>>
Returns the end time of the price history bounds.
Sourcepub fn is_range_available(
&self,
range_from: DateTime<Utc>,
range_to: DateTime<Utc>,
) -> Result<bool, SyncPriceHistoryError>
pub fn is_range_available( &self, range_from: DateTime<Utc>, range_to: DateTime<Utc>, ) -> Result<bool, SyncPriceHistoryError>
Checks if a specified time range is fully available without gaps.
Sourcepub fn tail_continuous_duration(&self) -> Option<Duration>
pub fn tail_continuous_duration(&self) -> Option<Duration>
Returns the duration of continuous (gap-free) price history at the tail end.
This is the time span from the end of the most recent gap to the latest data point. If there are no gaps, returns the total duration of all available price history.
Sourcepub fn has_gaps(&self) -> Result<bool, SyncPriceHistoryError>
pub fn has_gaps(&self) -> Result<bool, SyncPriceHistoryError>
Checks whether there are any gaps or missing data within the reach period.
Trait Implementations§
Source§impl Clone for PriceHistoryState
impl Clone for PriceHistoryState
Source§fn clone(&self) -> PriceHistoryState
fn clone(&self) -> PriceHistoryState
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PriceHistoryState
impl Debug for PriceHistoryState
Source§impl Display for PriceHistoryState
impl Display for PriceHistoryState
Source§impl From<PriceHistoryState> for SyncUpdate
impl From<PriceHistoryState> for SyncUpdate
Source§fn from(value: PriceHistoryState) -> Self
fn from(value: PriceHistoryState) -> Self
Source§impl PartialEq for PriceHistoryState
impl PartialEq for PriceHistoryState
impl Eq for PriceHistoryState
impl StructuralPartialEq for PriceHistoryState
Auto Trait Implementations§
impl Freeze for PriceHistoryState
impl RefUnwindSafe for PriceHistoryState
impl Send for PriceHistoryState
impl Sync for PriceHistoryState
impl Unpin for PriceHistoryState
impl UnwindSafe for PriceHistoryState
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read moreSource§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.