use serve_net::{Envelope, Verdict};
use crate::RequestId;
#[non_exhaustive]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum EventKind {
Refused,
Denied,
Failed,
Panicked,
Revoked,
}
#[non_exhaustive]
#[derive(Debug)]
pub struct Event<'a> {
pub kind: EventKind,
pub id: RequestId,
pub route: Option<&'a str>,
pub status: u16,
pub code: &'static str,
pub source: Option<&'a (dyn std::error::Error + 'static)>,
}
pub trait Events: Send + Sync + 'static {
fn event(&self, event: &Event<'_>) {
let _ = event;
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct NoEvents;
impl Events for NoEvents {}
#[non_exhaustive]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Stage {
Authorized,
BeforeRender,
}
pub trait Checkpoint: Send + Sync + 'static {
fn check(&self, env: &Envelope, at: Stage) -> Verdict;
}