use postrust_auth::{JwtCache, JwtConfig};
use postrust_core::db::{Db, MaybeSend, MaybeSync};
use postrust_core::{AppConfig, SchemaCache};
use std::future::Future;
use std::ops::Deref;
pub trait State: MaybeSync {
type Db: Db;
type SchemaCache<'a>: Deref<Target = SchemaCache> + MaybeSend + MaybeSync
where
Self: 'a;
fn db(&self) -> &Self::Db;
fn schema_cache(&self) -> impl Future<Output = Self::SchemaCache<'_>> + MaybeSend;
fn config(&self) -> &AppConfig;
fn jwt_config(&self) -> &JwtConfig;
fn jwt_cache(&self) -> Option<&JwtCache>;
fn default_schema(&self) -> &str {
self.config().default_schema()
}
fn schemas(&self) -> &[String] {
&self.config().db_schemas
}
}