Skip to main content

sark_http/h1/codec/decode/request/
mod.rs

1use core::convert::Infallible;
2
3use crate::h1::head::ParseError;
4
5mod head;
6
7pub use head::Head;
8
9#[derive(PartialEq, Eq)]
10pub enum Admission {
11    NeedMore,
12    Bad(ParseError<Infallible>),
13    Ready,
14}
15
16impl Admission {
17    #[cold]
18    pub fn admit(input: &[u8]) -> Self {
19        match Head::scan(input, input.len()).map(|head| head.is_some()) {
20            Ok(true) => Self::Ready,
21            Ok(false) => Self::NeedMore,
22            Err(cause) => Self::Bad(cause),
23        }
24    }
25}