use crate::event::DeliveredEvent;
pub struct Subscription {
request_id: String,
rx: tokio::sync::mpsc::Receiver<crate::Result<DeliveredEvent>>,
}
impl Subscription {
pub(crate) fn new(
request_id: String,
rx: tokio::sync::mpsc::Receiver<crate::Result<DeliveredEvent>>,
) -> Self {
Self { request_id, rx }
}
pub fn request_id(&self) -> &str {
&self.request_id
}
pub async fn next(&mut self) -> Option<crate::Result<DeliveredEvent>> {
self.rx.recv().await
}
pub fn into_parts(
self,
) -> (
String,
tokio::sync::mpsc::Receiver<crate::Result<DeliveredEvent>>,
) {
(self.request_id, self.rx)
}
}