chartml_core/plugin/
data_source.rs1use async_trait::async_trait;
2use crate::data::DataTable;
3use crate::error::ChartError;
4
5#[derive(Debug, Clone, Default)]
7pub struct FetchOptions {
8 pub cache_ttl: Option<String>,
10}
11
12#[derive(Debug, Clone)]
14pub struct DataSpec {
15 pub provider: String,
17 pub rows: Option<Vec<serde_json::Value>>,
19 pub url: Option<String>,
21 pub endpoint: Option<String>,
23}
24
25#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
27#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
28pub trait DataSource: Send + Sync {
29 async fn fetch(&self, spec: &DataSpec, options: &FetchOptions) -> Result<DataTable, ChartError>;
31}