use crate::types::version_metadata::Version;
use crate::types::VersionInfo;
use lighty_core::QueryError;
use async_trait::async_trait;
use std::hash::Hash;
pub type Result<T> = std::result::Result<T, QueryError>;
#[async_trait]
pub trait Query: Send + Sync {
type Query: Eq + Hash + Clone + Send + Sync + 'static;
type Data: Clone + Send + Sync + 'static;
type Raw: Send + Sync + 'static;
fn name() -> &'static str;
async fn fetch_full_data<V: VersionInfo>(version: &V) -> Result<Self::Raw>;
async fn extract<V: VersionInfo>(version: &V, query: &Self::Query, raw: &Self::Raw) -> Result<Self::Data>;
async fn version_builder<V: VersionInfo>(version: &V, full_data: &Self::Raw) -> Result<Version>;
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct QueryKey<Q> {
pub version: String,
pub query: Q,
}