use std::{error::Error as StdError, future::Future, time::Duration};
use crate::{Broker, Publisher, RawMessage, Subscriber};
pub trait TestClient: Send {
type Broker: Broker;
type Subscriber: Subscriber;
type Publisher: Publisher;
type Error: StdError + Send + Sync + 'static;
fn start() -> impl Future<Output = Result<Self, Self::Error>> + Send
where
Self: Sized;
fn broker(&self) -> &Self::Broker;
fn publish(
&self,
name: &str,
payload: &[u8],
) -> impl Future<Output = Result<(), Self::Error>> + Send;
fn subscribe(
&self,
name: &str,
) -> impl Future<Output = Result<Self::Subscriber, Self::Error>> + Send;
fn publisher(&self) -> impl Future<Output = Result<Self::Publisher, Self::Error>> + Send;
fn expect_published(
&self,
name: &str,
count: usize,
timeout: Duration,
) -> impl Future<Output = Result<Vec<RawMessage>, Self::Error>> + Send;
fn shutdown(self) -> impl Future<Output = Result<(), Self::Error>> + Send;
}