use ::std::sync::Arc;
use ::async_trait::async_trait;
use ::bytes::Bytes;
use ::futures::stream::BoxStream;
#[cfg(test)]
use ::mockall::automock;
use super::errors::BrokerError;
use crate::traits::AckTrait;
#[cfg_attr(test, automock)]
#[async_trait]
pub trait PubBrokerTrait {
async fn publish(
&self,
topic: &str,
payload: Bytes,
) -> Result<(), BrokerError>;
}
#[async_trait]
pub trait SubBrokerTrait {
async fn subscribe(
&self,
) -> Result<
BoxStream<Result<(Bytes, Arc<dyn AckTrait + Send + Sync>), BrokerError>>,
BrokerError,
>;
}
#[cfg(test)]
mod tests {
use ::static_assertions::assert_obj_safe;
use super::*;
#[test]
fn test_pubctx_safety() {
assert_obj_safe!(PubBrokerTrait);
}
#[test]
fn test_subctx_safety() {
assert_obj_safe!(SubBrokerTrait);
}
}