use sark_http::{method, payload::response::dispatch};
use crate::{
decode, manifold,
request::path,
route::{self, guard},
};
pub struct Key<'a> {
method: method::Known,
target: &'a [u8],
protocol: Option<&'a [u8]>,
}
impl<'a> Key<'a> {
pub const fn new(method: method::Known, target: &'a [u8], protocol: Option<&'a [u8]>) -> Self {
Self {
method,
target,
protocol,
}
}
#[doc(hidden)]
pub const fn into_parts(self) -> (method::Known, &'a [u8], Option<&'a [u8]>) {
(self.method, self.target, self.protocol)
}
}
pub trait Sync<S>: route::Spec<Kind = dispatch::Sync> + manifold::Route<S> {}
impl<S, R> Sync<S> for R where R: route::Spec<Kind = dispatch::Sync> + manifold::Route<S> {}
pub trait Slot<S>: guard::Slot<S> {
type Set;
type Route: route::Spec;
const INDEX: u32;
}
pub trait Visit<S, Set> {
type Output;
fn visit<'a, P>(
self,
target: path::Target<'a>,
path_end: usize,
captures: <<<P::Route as route::Spec>::Request as route::Schema>::RawParams as route::RawParams>::Captures,
) -> Self::Output
where
P: Slot<S, Set = Set>,
P::Route: Sync<S>;
}
pub trait Each<S, Set> {
type Output;
fn each<P>(self) -> Self::Output
where
P: Slot<S, Set = Set>,
P::Route: Sync<S>;
}
pub trait Router: decode::Decode {
type State;
type Table: route::raw::Table<Self::State>;
fn state(&self) -> &Self::State;
}