Skip to main content

sark_http/owner/handoff/
mod.rs

1//! Linear response ownership handoff.
2
3use o3::buffer::hold;
4
5use crate::{payload::owned, request::body};
6
7/// One affine choice of how to project a request source.
8pub trait Project<'d>: Sized {
9    type Proof: stage::Proof;
10    type Owner;
11
12    fn contiguous<V, T>(
13        self,
14        value: V,
15        project: impl for<'req> FnOnce(
16            V,
17            body::View<'req, 'd>,
18            Slot<'req, 'd, (), input::Bound<'req, 'd, Self::Proof>>,
19        ) -> T,
20    ) -> Result<(T, Self::Owner), (Self, V, body::Error)>;
21
22    fn segmented<V, T>(
23        self,
24        value: V,
25        project: impl for<'req> FnOnce(
26            V,
27            body::Ref<'req, 'd>,
28            Slot<'req, 'd, (), input::Bound<'req, 'd, Self::Proof>>,
29        ) -> T,
30    ) -> (T, Self::Owner);
31
32    fn discarded<V, T>(
33        self,
34        value: V,
35        project: impl for<'req> FnOnce(V, Slot<'req, 'd, (), input::Bound<'req, 'd, Self::Proof>>) -> T,
36    ) -> (T, Self::Owner);
37}
38
39pub mod copy;
40pub mod input;
41mod origin;
42mod pending;
43mod plan;
44mod ready;
45mod slot;
46pub mod stage;
47
48#[derive(Clone, Debug, PartialEq, Eq)]
49pub enum Error {
50    Retain(owned::Error),
51    Overflow(hold::Overflow),
52}
53
54pub(crate) use origin::Origin;
55pub use pending::Pending;
56pub use plan::Plan;
57pub(crate) use plan::State;
58pub use ready::Ready;
59pub use slot::Slot;
60
61const _: () = assert!(size_of::<Error>() <= 4 * size_of::<usize>());