#![warn(missing_docs)]
mod csv;
mod gpkg;
mod pg;
mod sql;
mod types;
pub use csv::*;
pub use gpkg::*;
pub use pg::*;
pub use types::*;
use crate::{Expression, Q};
use async_trait::async_trait;
use futures::stream::BoxStream;
use std::collections::HashMap;
pub type Resource = HashMap<String, Q>;
pub trait DataSource {
fn srid(&self) -> Option<u32>;
}
pub trait IterableDS {
type Item: TryInto<Resource, Error = Self::Err>;
type Err;
fn iter(&self) -> Result<impl Iterator<Item = Result<Self::Item, Self::Err>>, Self::Err>;
}
#[async_trait]
pub trait StreamableDS {
type Item: TryInto<Resource, Error = Self::Err>;
type Err;
async fn fetch(&self) -> Result<BoxStream<'_, Result<Self::Item, Self::Err>>, Self::Err>;
async fn stream(&self) -> Result<BoxStream<'_, Result<Resource, Self::Err>>, Self::Err>;
async fn fetch_where(
&self,
exp: &Expression,
) -> Result<BoxStream<'_, Result<Self::Item, Self::Err>>, Self::Err>;
async fn stream_where(
&self,
exp: &Expression,
) -> Result<BoxStream<'_, Result<Resource, Self::Err>>, Self::Err>;
}