clipboard_stream/
stream.rs1use std::{
2 pin::Pin,
3 task::{Context, Poll},
4};
5
6use futures::{Stream, channel::mpsc::Receiver};
7
8use crate::{
9 Msg,
10 body::{Body, BodySendersDropHandle, Kind},
11};
12
13#[derive(Debug)]
31pub struct ClipboardStream {
32 pub(crate) body_rx: Pin<Box<Receiver<Msg>>>,
33 pub(crate) kind: Kind,
34 pub(crate) drop_handle: BodySendersDropHandle,
35}
36
37impl Stream for ClipboardStream {
38 type Item = Result<Body, crate::error::Error>;
39
40 fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
41 self.body_rx.as_mut().poll_next(cx)
42 }
43}
44
45impl Drop for ClipboardStream {
46 fn drop(&mut self) {
47 self.drop_handle.drop(&self.kind);
48 }
49}