Skip to main content

sark_http/h1/codec/decode/
fields.rs

1use o3::alloc;
2
3use crate::{field::storage, h1::field::Entry};
4
5#[derive(Debug)]
6pub enum Error {
7    Name(storage::Error),
8    Value(storage::Error),
9    Allocation(alloc::Error),
10}
11
12/// Consumer for one syntactically admitted HTTP/1 field section.
13/// Fields borrow the wire input; the sink chooses borrowing, compact state,
14/// or explicit materialization without another wire traversal.
15pub trait Sink<'input> {
16    type Error;
17
18    fn push(&mut self, name: &'input [u8], value: &'input [u8]) -> Result<(), Self::Error>;
19
20    /// Retains the scanner's syntax proof when materializing an admitted field.
21    fn entry(&mut self, field: Entry<'input>) -> Result<(), Self::Error> {
22        self.push(field.name(), field.value())
23    }
24}
25
26const _: () = assert!(core::mem::size_of::<Error>() <= 3 * core::mem::size_of::<usize>());