Skip to main content

sark_core/body/admit/
mod.rs

1mod advance;
2mod bound;
3mod error;
4mod plan;
5mod start;
6mod track;
7
8pub(in crate::body) use advance::Advance;
9use bound::{Bound, Kind};
10pub use error::Error;
11pub use plan::Plan;
12pub use start::Start;
13pub use track::Track;
14
15/// Whether framing must retain request payload bytes.
16#[derive(Clone, Copy, PartialEq, Eq, Debug)]
17pub enum Retention {
18    Retained,
19    Discarded,
20}
21
22/// Whether a request builder may consume body segments before transport FIN.
23#[derive(Clone, Copy, PartialEq, Eq, Debug)]
24pub enum Stream {
25    Streaming,
26    Buffered,
27}
28
29const _: () = assert!(core::mem::size_of::<Stream>() == 1);
30
31/// Whether the complete logical body length was present in the request head.
32#[derive(Clone, Copy, PartialEq, Eq)]
33pub enum Length {
34    Known(usize),
35    Unknown,
36}
37
38impl Length {
39    pub const fn from_option(value: Option<usize>) -> Self {
40        match value {
41            Some(value) => Self::Known(value),
42            None => Self::Unknown,
43        }
44    }
45}
46
47const _: () = assert!(core::mem::size_of::<Length>() == 2 * core::mem::size_of::<usize>());
48
49/// Input may still advance the admitted logical length.
50#[derive(Debug)]
51pub struct Open;
52
53/// Input ended and its logical length satisfies the admitted bound.
54#[derive(Debug)]
55pub struct Finished;