Open AnatolyBuga opened 1 year ago
It would be better if DataSource was a Trait.
Trait
//TODO - consider this: /// Trait which defines the behavior of a a Source of Data /// examples: pub trait DataSource: Send + Sync { fn get_lazyframe(&self, filters: &AndOrFltrChain) -> UltiResult<LazyFrame>; fn get_column(&self, col_name: &str) -> UltiResult<Series> ; fn get_schema(&self) -> UltiResult<Arc<Schema>>; /// InMemory -> false /// Scan -> true /// Db -> true fn prepare_on_each_request(&self) -> bool; } // As per example: use std::sync::Arc; struct Empty; struct Null; trait P { fn u(&self) -> u8 where Self: Sized {1} } impl P for Empty{} trait GeeksforGeeks{ type X; fn gfg_func(&self) -> Self::X; } impl <U> GeeksforGeeks for U { type X = Arc<dyn P>; fn gfg_func(&self) -> Self::X { Arc::new(Empty{}) } } fn main() { let variable_one = Empty; let variable_two = Null; let obj: Box<dyn GeeksforGeeks<X=Arc<dyn P>>> = Box::new(variable_two); obj.gfg_func(); }
It would be better if DataSource was a
Trait
.