1use sark_http::{method, payload::response::dispatch};
4
5use crate::{
6 decode, manifold,
7 request::path,
8 route::{self, guard},
9};
10
11pub struct Key<'a> {
13 method: method::Known,
14 target: &'a [u8],
15 protocol: Option<&'a [u8]>,
16}
17
18impl<'a> Key<'a> {
19 pub const fn new(method: method::Known, target: &'a [u8], protocol: Option<&'a [u8]>) -> Self {
20 Self {
21 method,
22 target,
23 protocol,
24 }
25 }
26
27 #[doc(hidden)]
28 pub const fn into_parts(self) -> (method::Known, &'a [u8], Option<&'a [u8]>) {
29 (self.method, self.target, self.protocol)
30 }
31}
32
33pub trait Sync<S>: route::Spec<Kind = dispatch::Sync> + manifold::Route<S> {}
35
36impl<S, R> Sync<S> for R where R: route::Spec<Kind = dispatch::Sync> + manifold::Route<S> {}
37
38pub trait Slot<S>: guard::Slot<S> {
40 type Set;
41 type Route: route::Spec;
42
43 const INDEX: u32;
44}
45
46pub trait Visit<S, Set> {
49 type Output;
50
51 fn visit<'a, P>(
52 self,
53 target: path::Target<'a>,
54 path_end: usize,
55 captures: <<<P::Route as route::Spec>::Request as route::Schema>::RawParams as route::RawParams>::Captures,
56 ) -> Self::Output
57 where
58 P: Slot<S, Set = Set>,
59 P::Route: Sync<S>;
60}
61
62pub trait Each<S, Set> {
64 type Output;
65
66 fn each<P>(self) -> Self::Output
67 where
68 P: Slot<S, Set = Set>,
69 P::Route: Sync<S>;
70}
71
72pub trait Router: decode::Decode {
74 type State;
75 type Table: route::raw::Table<Self::State>;
76
77 fn state(&self) -> &Self::State;
78}