use crate::prelude::IggyClient;
use async_trait::async_trait;
use iggy_common::TopicClient;
use iggy_common::locking::IggyRwLockFn;
use iggy_common::{
Identifier, IggyError, Topic, TopicCreateOptions, TopicDetails, TopicUpdateOptions,
};
#[async_trait]
impl TopicClient for IggyClient {
async fn get_topic(
&self,
stream_id: &Identifier,
topic_id: &Identifier,
) -> Result<Option<TopicDetails>, IggyError> {
self.client
.read()
.await
.get_topic(stream_id, topic_id)
.await
}
async fn get_topics(&self, stream_id: &Identifier) -> Result<Vec<Topic>, IggyError> {
self.client.read().await.get_topics(stream_id).await
}
async fn create_topic(
&self,
stream_id: &Identifier,
name: &str,
options: &TopicCreateOptions,
) -> Result<TopicDetails, IggyError> {
self.client
.read()
.await
.create_topic(stream_id, name, options)
.await
}
async fn update_topic(
&self,
stream_id: &Identifier,
topic_id: &Identifier,
name: &str,
options: &TopicUpdateOptions,
) -> Result<(), IggyError> {
self.client
.read()
.await
.update_topic(stream_id, topic_id, name, options)
.await
}
async fn delete_topic(
&self,
stream_id: &Identifier,
topic_id: &Identifier,
) -> Result<(), IggyError> {
self.client
.read()
.await
.delete_topic(stream_id, topic_id)
.await
}
async fn purge_topic(
&self,
stream_id: &Identifier,
topic_id: &Identifier,
) -> Result<(), IggyError> {
self.client
.read()
.await
.purge_topic(stream_id, topic_id)
.await
}
}