DataRefreshManager

Struct DataRefreshManager 

Source
pub struct DataRefreshManager { /* private fields */ }
Expand description

Manages periodic data refresh for data sources.

Implementations§

Source§

impl DataRefreshManager

Source

pub const fn new() -> Self

Create a new refresh manager.

Source

pub fn register(&mut self, key: impl Into<String>, interval_ms: u64)

Register a data source for periodic refresh.

§Arguments
  • key - Data source identifier
  • interval_ms - Refresh interval in milliseconds
Source

pub fn unregister(&mut self, key: &str)

Unregister a data source.

Source

pub fn pause(&mut self, key: &str)

Pause refresh for a data source.

Source

pub fn resume(&mut self, key: &str)

Resume refresh for a data source.

Source

pub fn update(&mut self, current_time_ms: u64) -> Vec<String>

Update the manager with the current timestamp.

Returns keys of data sources that need to be refreshed.

Source

pub fn force_refresh(&mut self, key: &str) -> bool

Force immediate refresh of a data source.

Source

pub fn tasks(&self) -> &[RefreshTask]

Get all registered tasks.

Source

pub fn get_task(&self, key: &str) -> Option<&RefreshTask>

Get task by key.

Source

pub fn is_due(&self, key: &str) -> bool

Check if a data source is due for refresh.

Source

pub fn time_until_refresh(&self, key: &str) -> Option<u64>

Get time until next refresh for a data source (in ms).

Trait Implementations§

Source§

impl Debug for DataRefreshManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DataRefreshManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.