apalis_board_api/sse/
client.rs1use std::{
2 pin::Pin,
3 task::{Context, Poll},
4};
5
6use apalis_board_types::LogEntry;
7use futures::{
8 Stream, StreamExt,
9 channel::mpsc::{Receiver, TryRecvError},
10};
11
12#[derive(Debug)]
14pub struct Client(pub(crate) Receiver<LogEntry>);
15
16impl Stream for Client {
17 type Item = Result<LogEntry, TryRecvError>;
18
19 fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
20 self.0.poll_next_unpin(cx).map(|c| Ok(c).transpose())
21 }
22}