Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

DataSource as a Trait #167

Open
AnatolyBuga opened this issue Aug 13, 2023 · 0 comments
Open

DataSource as a Trait #167

AnatolyBuga opened this issue Aug 13, 2023 · 0 comments
Labels
rust Rust Backend

Comments

@AnatolyBuga
Copy link
Member

It would be better if DataSource was a 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();

}
@AnatolyBuga AnatolyBuga added the rust Rust Backend label Aug 13, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
rust Rust Backend
Projects
None yet
Development

No branches or pull requests

1 participant