use crate::Remap;
use std::fmt::Debug;
use std::future::Future;
use std::pin::Pin;
use std::task::Context;
use std::task::Poll;
pub struct Listener(Box<dyn crate::raw::Listener>);
impl Debug for Listener {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Listener")
}
}
impl Default for Listener {
fn default() -> Self {
Self::new(Remap::default())
}
}
impl Listener {
pub fn new(remap: Remap) -> Self {
Self(crate::raw::GLOBAL.with(|g| g.listener(remap)))
}
}
impl Future for Listener {
type Output = crate::Controller;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
Pin::new(&mut self.get_mut().0).poll(cx)
}
}