use ruststream::asyncapi::{Binding, Bindings};
use serde::Serialize;
use crate::topic::PulsarTopic;
const BINDING_VERSION: &str = "0.1.0";
pub(crate) fn one<T: Serialize>(protocol: &'static str, body: &T) -> Bindings {
Binding::new(protocol, BINDING_VERSION, body)
.map(|binding| Bindings::new().with(binding))
.unwrap_or_default()
}
pub(crate) fn extension<T: Serialize>(name: &'static str, body: &T) -> Bindings {
Binding::extension(name, body)
.map(|binding| Bindings::new().with(binding))
.unwrap_or_default()
}
#[derive(Serialize)]
struct PulsarChannel<'a> {
namespace: &'a str,
persistence: &'a str,
}
pub(crate) fn topic_channel(topic: &PulsarTopic) -> Bindings {
let body = PulsarChannel {
namespace: topic.namespace(),
persistence: topic.persistence(),
};
one("pulsar", &body)
}