use crate::quic::connection::ConnectionHandle;
#[derive(Default)]
pub struct Wakeups {
wakers: Vec<std::task::Waker>,
}
impl Wakeups {
pub fn schedule(&mut self, w: std::task::Waker) {
self.wakers.push(w);
}
pub(crate) fn fire(&mut self) {
while let Some(w) = self.wakers.pop() {
w.wake();
}
}
}
pub trait QuicScionApplication: Send {
type Config;
fn on_established(conn: &mut squiche::Connection, config: &Self::Config) -> Self
where
Self: Sized;
fn bind(&mut self, handle: &ConnectionHandle<Self>)
where
Self: Sized,
{
let _ = handle;
}
fn update(&mut self, conn: &mut squiche::Connection, wakeups: &mut Wakeups);
fn on_closed(&mut self, wakeups: &mut Wakeups);
}
pub struct NoApp;
impl QuicScionApplication for NoApp {
type Config = ();
fn on_established(_conn: &mut squiche::Connection, _config: &()) -> Self {
NoApp
}
fn update(&mut self, _: &mut squiche::Connection, _: &mut Wakeups) {}
fn on_closed(&mut self, _: &mut Wakeups) {}
}