use crate::payload::response::Method;
use core::convert::Infallible;
use crate::h1::head::{Limit, ParseError, field, response::Parts, state};
#[repr(transparent)]
pub struct State(state::State<Method>);
impl State {
pub const fn new(request: Method, limit: Limit) -> Self {
Self(state::State::new(request, limit))
}
pub unsafe fn advance_from<'owner, E>(
self,
source: &'owner [u8],
sink: impl FnMut(field::Entry<'owner>) -> Result<(), E>,
) -> Result<(Self, Option<Parts>), ParseError<E>> {
let (state, parts) = self.0.parse(source, sink)?;
Ok((Self(state), parts))
}
pub unsafe fn scan_from(
self,
source: &[u8],
) -> Result<(Self, Option<Parts>), ParseError<Infallible>> {
let (state, parts) = self.0.scan(source)?;
Ok((Self(state), parts))
}
}