use std::collections::HashSet;
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use tokio::sync::broadcast::Receiver;
use super::{
error::Result,
models::{
rpc::{AuthenticateResult, HelloResult, WhoamiResult},
topic::StreamTopic,
update::StreamUpdate,
},
state::StreamConnectionStatus,
};
#[async_trait]
pub trait StreamRepository: crate::sealed::Sealed + Send + Sync {
async fn is_connected(&self) -> bool;
async fn connection_status(&self) -> StreamConnectionStatus;
async fn hello(&self, client_name: &str, client_version: &str) -> Result<HelloResult>;
async fn ping(&self) -> Result<()>;
async fn time(&self) -> Result<DateTime<Utc>>;
async fn authenticate(
&self,
key: &str,
secret: &str,
passphrase: &str,
) -> Result<AuthenticateResult>;
async fn whoami(&self) -> Result<WhoamiResult>;
async fn subscribe(&self, topics: Vec<StreamTopic>) -> Result<()>;
async fn unsubscribe(&self, topics: Vec<StreamTopic>) -> Result<()>;
async fn unsubscribe_all(&self) -> Result<Vec<StreamTopic>>;
async fn subscriptions(&self) -> HashSet<StreamTopic>;
async fn receiver(&self) -> Result<Receiver<StreamUpdate>>;
async fn disconnect(&self) -> Result<()>;
}