rustsmb/io/state.rs
1//! Lifecycle states of an [`IoContext`](super::IoContext).
2//!
3//! A state is a *type*: operations are only defined on the `IoContext<State>`
4//! where they are legal, and a transition consumes the old state to yield the
5//! new one, so illegal lifecycles fail to compile.
6
7mod sealed {
8 pub trait Sealed {}
9}
10
11/// A lifecycle state marker for an [`IoContext`](super::IoContext). Sealed: the
12/// set of states is closed to this crate.
13pub trait IoState: sealed::Sealed {}
14
15// Data-less states (generated). `Accepted`: parsed and ready to serve.
16// `Completed`: a final response has been produced and the context is spent.
17io_states!(Accepted, Completed);
18
19/// Deferred (STATUS_PENDING) state: an interim reply was sent and the final
20/// reply is owed. Carries the async correlation id so it is *only* reachable
21/// once a request has actually been deferred — you cannot complete work that was
22/// never parked.
23#[derive(Debug)]
24pub struct Pending {
25 pub(crate) async_id: u64,
26}
27
28impl sealed::Sealed for Pending {}
29impl IoState for Pending {}