pub trait Source {
type TypeSystem: TypeSystem;
type Partition: SourcePartition<TypeSystem = Self::TypeSystem, Error = Self::Error> + Send;
type Error: From<ConnectorXError> + Send + Debug;
const DATA_ORDERS: &'static [DataOrder];
// Required methods
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>;
// Provided method
fn set_pre_execution_queries(
&mut self,
_pre_execution_queries: Option<&[String]>,
) { ... }
}Expand description
A Source connects to a database, fetches the metadata of a query and splits the work into
SourcePartitions, one per partitioned query.
Dispatcher drives a Source in this order:
set_data_order, set_queries,
set_origin_query, fetch_metadata,
then schema and names, optionally
result_rows, and finally partition.
Required Associated Constants§
Sourceconst DATA_ORDERS: &'static [DataOrder]
const DATA_ORDERS: &'static [DataOrder]
Supported data orders, ordering by preference.
Required Associated Types§
Sourcetype TypeSystem: TypeSystem
type TypeSystem: TypeSystem
The type system this Source associated with.
Sourcetype Partition: SourcePartition<TypeSystem = Self::TypeSystem, Error = Self::Error> + Send
type Partition: SourcePartition<TypeSystem = Self::TypeSystem, Error = Self::Error> + Send
The partition type produced by partition. It is sent to a worker
thread, so it must be Send.
Required Methods§
Sourcefn set_data_order(&mut self, data_order: DataOrder) -> Result<(), Self::Error>
fn set_data_order(&mut self, data_order: DataOrder) -> Result<(), Self::Error>
Set the data order negotiated between this source and the destination, one of
DATA_ORDERS. Return an error if the order is not supported.
Sourcefn set_queries<Q: ToString>(&mut self, queries: &[CXQuery<Q>])
fn set_queries<Q: ToString>(&mut self, queries: &[CXQuery<Q>])
Set the partitioned queries. Each query becomes one SourcePartition.
Sourcefn set_origin_query(&mut self, query: Option<String>)
fn set_origin_query(&mut self, query: Option<String>)
Set the original, unpartitioned query, if there is one. Sources can use it to
count the rows of the whole result in result_rows.
Sourcefn fetch_metadata(&mut self) -> Result<(), Self::Error>
fn fetch_metadata(&mut self) -> Result<(), Self::Error>
Sourcefn result_rows(&mut self) -> Result<Option<usize>, Self::Error>
fn result_rows(&mut self) -> Result<Option<usize>, Self::Error>
Get total number of rows if available.
Return Ok(None) when the total cannot be derived; the dispatcher then counts each
partition with SourcePartition::result_rows instead.
Sourcefn names(&self) -> Vec<String>
fn names(&self) -> Vec<String>
The column names of the result, available after fetch_metadata.
Sourcefn schema(&self) -> Vec<Self::TypeSystem>
fn schema(&self) -> Vec<Self::TypeSystem>
The column types of the result, available after fetch_metadata.
Provided Methods§
Sourcefn set_pre_execution_queries(
&mut self,
_pre_execution_queries: Option<&[String]>,
)
fn set_pre_execution_queries( &mut self, _pre_execution_queries: Option<&[String]>, )
Set queries to run on each connection before the partitioned queries. The default implementation panics; sources that support it override it.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".