use std::{
pin::Pin,
task::{Context, Poll},
};
use futures::{Stream, channel::mpsc::Receiver};
use crate::{
Msg,
body::{Body, BodySendersDropHandle, Kind},
};
#[derive(Debug)]
pub struct ClipboardStream {
pub(crate) body_rx: Pin<Box<Receiver<Msg>>>,
pub(crate) kind: Kind,
pub(crate) drop_handle: BodySendersDropHandle,
}
impl Stream for ClipboardStream {
type Item = Result<Body, crate::error::Error>;
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
self.body_rx.as_mut().poll_next(cx)
}
}
impl Drop for ClipboardStream {
fn drop(&mut self) {
self.drop_handle.drop(&self.kind);
}
}