pub struct DataManager { /* private fields */ }Expand description
数据管理器
管理所有 DIFF 协议数据,支持:
- 递归合并
- 版本追踪
- 路径监听
Implementations§
Source§impl DataManager
impl DataManager
Sourcepub fn new(
initial_data: HashMap<String, Value>,
config: DataManagerConfig,
) -> Self
pub fn new( initial_data: HashMap<String, Value>, config: DataManagerConfig, ) -> Self
创建新的数据管理器
Sourcepub fn merge_data(&self, source: Value, epoch_increase: bool, delete_null: bool)
pub fn merge_data(&self, source: Value, epoch_increase: bool, delete_null: bool)
Sourcepub fn get_by_path(&self, path: &[&str]) -> Option<Value>
pub fn get_by_path(&self, path: &[&str]) -> Option<Value>
根据路径获取数据
Sourcepub fn is_changing(&self, path: &[&str]) -> bool
pub fn is_changing(&self, path: &[&str]) -> bool
判断指定路径的数据是否在最近一次更新中发生了变化
Sourcepub fn watch(&self, path: Vec<String>) -> Receiver<Value>
pub fn watch(&self, path: Vec<String>) -> Receiver<Value>
监听指定路径的数据变化
返回一个 receiver,数据变化时会推送到这个 channel
Sourcepub fn convert_to_struct<T: DeserializeOwned>(&self, data: &Value) -> Result<T>
pub fn convert_to_struct<T: DeserializeOwned>(&self, data: &Value) -> Result<T>
转换为结构体
Sourcepub fn get_quote_data(&self, symbol: &str) -> Result<Quote>
pub fn get_quote_data(&self, symbol: &str) -> Result<Quote>
获取 Quote 数据
Sourcepub fn get_klines_data(
&self,
symbol: &str,
duration: i64,
view_width: usize,
right_id: i64,
) -> Result<KlineSeriesData>
pub fn get_klines_data( &self, symbol: &str, duration: i64, view_width: usize, right_id: i64, ) -> Result<KlineSeriesData>
获取 K线数据
Sourcepub fn get_multi_klines_data(
&self,
symbols: &[String],
duration: i64,
chart_id: &str,
view_width: usize,
) -> Result<MultiKlineSeriesData>
pub fn get_multi_klines_data( &self, symbols: &[String], duration: i64, chart_id: &str, view_width: usize, ) -> Result<MultiKlineSeriesData>
获取多合约对齐的 K线数据
Sourcepub fn get_ticks_data(
&self,
symbol: &str,
view_width: usize,
right_id: i64,
) -> Result<TickSeriesData>
pub fn get_ticks_data( &self, symbol: &str, view_width: usize, right_id: i64, ) -> Result<TickSeriesData>
获取 Tick 数据
Auto Trait Implementations§
impl !Freeze for DataManager
impl RefUnwindSafe for DataManager
impl Send for DataManager
impl Sync for DataManager
impl Unpin for DataManager
impl UnwindSafe for DataManager
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
Mutably borrows from an owned value. Read more