winit/src/platform_impl/web/event_loop/proxy.rs

27 lines
556 B
Rust
Raw Normal View History

2019-06-25 03:15:34 +02:00
use super::runner;
use crate::event::Event;
use crate::event_loop::EventLoopClosed;
2019-09-24 19:39:13 -04:00
pub struct Proxy<T: 'static>{
2019-06-25 03:15:34 +02:00
runner: runner::Shared<T>,
}
impl<T: 'static> Proxy<T> {
pub fn new(runner: runner::Shared<T>) -> Self {
Proxy { runner }
}
pub fn send_event(&self, event: T) -> Result<(), EventLoopClosed> {
self.runner.send_event(Event::UserEvent(event));
Ok(())
}
}
2019-09-24 19:39:13 -04:00
impl<T: 'static> Clone for Proxy<T> {
fn clone(&self) -> Self {
Proxy {
runner: self.runner.clone()
}
}
}