Create iced_futures and wire everything up
This commit is contained in:
parent
d50ff9b5d9
commit
b5b17ed4d8
23 changed files with 196 additions and 195 deletions
57
winit/src/proxy.rs
Normal file
57
winit/src/proxy.rs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
use futures::{
|
||||
task::{Context, Poll},
|
||||
Sink,
|
||||
};
|
||||
use std::pin::Pin;
|
||||
|
||||
pub struct Proxy<Message: 'static> {
|
||||
raw: winit::event_loop::EventLoopProxy<Message>,
|
||||
}
|
||||
|
||||
impl<Message: 'static> Clone for Proxy<Message> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
raw: self.raw.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<Message: 'static> Proxy<Message> {
|
||||
pub fn new(raw: winit::event_loop::EventLoopProxy<Message>) -> Self {
|
||||
Self { raw }
|
||||
}
|
||||
}
|
||||
|
||||
impl<Message: 'static> Sink<Message> for Proxy<Message> {
|
||||
type Error = core::convert::Infallible;
|
||||
|
||||
fn poll_ready(
|
||||
self: Pin<&mut Self>,
|
||||
_cx: &mut Context<'_>,
|
||||
) -> Poll<Result<(), Self::Error>> {
|
||||
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<Result<(), Self::Error>> {
|
||||
Poll::Ready(Ok(()))
|
||||
}
|
||||
|
||||
fn poll_close(
|
||||
self: Pin<&mut Self>,
|
||||
_cx: &mut Context<'_>,
|
||||
) -> Poll<Result<(), Self::Error>> {
|
||||
Poll::Ready(Ok(()))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue