connectorx/sources/
mod.rs#[cfg(feature = "src_bigquery")]
pub mod bigquery;
#[cfg(feature = "src_csv")]
pub mod csv;
#[cfg(feature = "src_dummy")]
pub mod dummy;
#[cfg(feature = "src_mssql")]
pub mod mssql;
#[cfg(feature = "src_mysql")]
pub mod mysql;
#[cfg(feature = "src_oracle")]
pub mod oracle;
#[cfg(feature = "src_postgres")]
pub mod postgres;
#[cfg(feature = "src_sqlite")]
pub mod sqlite;
#[cfg(feature = "src_trino")]
pub mod trino;
use crate::data_order::DataOrder;
use crate::errors::ConnectorXError;
use crate::sql::CXQuery;
use crate::typesystem::{TypeAssoc, TypeSystem};
use std::fmt::Debug;
pub trait Source {
const DATA_ORDERS: &'static [DataOrder];
type TypeSystem: TypeSystem;
type Partition: SourcePartition<TypeSystem = Self::TypeSystem, Error = Self::Error> + Send;
type Error: From<ConnectorXError> + Send + Debug;
fn set_data_order(&mut self, data_order: DataOrder) -> Result<(), Self::Error>;
fn set_queries<Q: ToString>(&mut self, queries: &[CXQuery<Q>]);
fn set_origin_query(&mut self, query: Option<String>);
fn fetch_metadata(&mut self) -> Result<(), Self::Error>;
fn result_rows(&mut self) -> Result<Option<usize>, Self::Error>;
fn names(&self) -> Vec<String>;
fn schema(&self) -> Vec<Self::TypeSystem>;
fn partition(self) -> Result<Vec<Self::Partition>, Self::Error>;
}
pub trait SourcePartition {
type TypeSystem: TypeSystem;
type Parser<'a>: PartitionParser<'a, TypeSystem = Self::TypeSystem, Error = Self::Error>
where
Self: 'a;
type Error: From<ConnectorXError> + Send + Debug;
fn result_rows(&mut self) -> Result<(), Self::Error>;
fn parser(&mut self) -> Result<Self::Parser<'_>, Self::Error>;
fn nrows(&self) -> usize;
fn ncols(&self) -> usize;
}
pub trait PartitionParser<'a>: Send {
type TypeSystem: TypeSystem;
type Error: From<ConnectorXError> + Send + Debug;
fn parse<'r, T>(&'r mut self) -> Result<T, <Self as PartitionParser<'a>>::Error>
where
T: TypeAssoc<Self::TypeSystem>,
Self: Produce<'r, T, Error = <Self as PartitionParser<'a>>::Error>,
{
self.produce()
}
fn fetch_next(&mut self) -> Result<(usize, bool), Self::Error>;
}
pub trait Produce<'r, T> {
type Error: From<ConnectorXError> + Send;
fn produce(&'r mut self) -> Result<T, Self::Error>;
}