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

27 lines
586 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;
pub struct EventLoopProxy<T: 'static> {
2019-06-25 03:15:34 +02:00
runner: runner::Shared<T>,
}
impl<T: 'static> EventLoopProxy<T> {
2019-06-25 03:15:34 +02:00
pub fn new(runner: runner::Shared<T>) -> Self {
Self { runner }
2019-06-25 03:15:34 +02:00
}
pub fn send_event(&self, event: T) -> Result<(), EventLoopClosed<T>> {
2019-06-25 03:15:34 +02:00
self.runner.send_event(Event::UserEvent(event));
Ok(())
}
}
2019-09-24 19:39:13 -04:00
impl<T: 'static> Clone for EventLoopProxy<T> {
2019-09-24 19:39:13 -04:00
fn clone(&self) -> Self {
Self {
runner: self.runner.clone(),
2019-09-24 19:39:13 -04:00
}
}
}