use iced_native::futures::{ task::{Context, Poll}, Sink, }; use std::pin::Pin; pub struct Proxy { raw: winit::event_loop::EventLoopProxy, } impl Clone for Proxy { fn clone(&self) -> Self { Self { raw: self.raw.clone(), } } } impl Proxy { pub fn new(raw: winit::event_loop::EventLoopProxy) -> Self { Self { raw } } } impl Sink for Proxy { type Error = core::convert::Infallible; fn poll_ready( self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> Poll> { Poll::Ready(Ok(())) } fn start_send( self: Pin<&mut Self>, message: Message, ) -> Result<(), Self::Error> { let _ = self.raw.send_event(message); Ok(()) } fn poll_flush( self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> Poll> { Poll::Ready(Ok(())) } fn poll_close( self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> Poll> { Poll::Ready(Ok(())) } }