use crate::client_wrappers::client_wrapper::ClientWrapper;
use async_broadcast::Receiver;
use async_trait::async_trait;
use iggy_common::Client;
use iggy_common::{DiagnosticEvent, IggyError};
#[async_trait]
impl Client for ClientWrapper {
async fn connect(&self) -> Result<(), IggyError> {
match self {
ClientWrapper::Iggy(client) => client.connect().await,
ClientWrapper::Http(client) => client.connect().await,
ClientWrapper::Tcp(client) => client.connect().await,
ClientWrapper::Quic(client) => client.connect().await,
ClientWrapper::WebSocket(client) => client.connect().await,
}
}
async fn disconnect(&self) -> Result<(), IggyError> {
match self {
ClientWrapper::Iggy(client) => client.disconnect().await,
ClientWrapper::Http(client) => client.disconnect().await,
ClientWrapper::Tcp(client) => client.disconnect().await,
ClientWrapper::Quic(client) => client.disconnect().await,
ClientWrapper::WebSocket(client) => client.disconnect().await,
}
}
async fn shutdown(&self) -> Result<(), IggyError> {
match self {
ClientWrapper::Iggy(client) => client.shutdown().await,
ClientWrapper::Http(client) => client.shutdown().await,
ClientWrapper::Tcp(client) => client.shutdown().await,
ClientWrapper::Quic(client) => client.shutdown().await,
ClientWrapper::WebSocket(client) => client.shutdown().await,
}
}
async fn subscribe_events(&self) -> Receiver<DiagnosticEvent> {
match self {
ClientWrapper::Iggy(client) => client.subscribe_events().await,
ClientWrapper::Http(client) => client.subscribe_events().await,
ClientWrapper::Tcp(client) => client.subscribe_events().await,
ClientWrapper::Quic(client) => client.subscribe_events().await,
ClientWrapper::WebSocket(client) => client.subscribe_events().await,
}
}
}