pub struct StatelessRequest<R, W> { /* private fields */ }Expand description
The stateless request/response substrate per POST (ADR-005 §2):
wraps (request-reader, response-writer, Limits,
Service) into the machinery that performs the
capability-dump skip, the delim-aware arg split, and the flush-only
probe rule on the read side, and hands the response rules to the
machine on the write side.
The transport-level error taxonomy is SubstrateError with the
duplex machinery’s semantics: terminal errors are cached and
re-reported without re-entering the transport (the unconditional
error-break rule, observable via
StatelessRequest::transport_reads).
Implementations§
Source§impl<R, W> StatelessRequest<R, W>
impl<R, W> StatelessRequest<R, W>
Sourcepub fn new(reader: R, writer: W, limits: Limits, service: Service) -> Self
pub fn new(reader: R, writer: W, limits: Limits, service: Service) -> Self
Wraps one POST’s (request-reader, response-writer, limits, service) per ADR-005 §2. The service rides the inputs per ADR-016 (the door’s route supplies it — nothing in the POST body distinguishes the services); dispatch on it is wave 2.
Sourcepub fn limits(&self) -> &Limits
pub fn limits(&self) -> &Limits
The session’s budget bundle (ADR-009; the request-body budget
is enforced by StatelessRequest::read_post, the rest is the
later waves’ machines’ to reach).
Sourcepub fn consumed_bytes(&self) -> u64
pub fn consumed_bytes(&self) -> u64
Request-body bytes consumed by the read side so far.
Sourcepub fn transport_reads(&self) -> u64
pub fn transport_reads(&self) -> u64
Transport read calls issued so far — the observable behind the unconditional error-break rule: after a terminal read error this counter must stop advancing.
Sourcepub fn response(&mut self) -> &mut StatelessResponse<W>
pub fn response(&mut self) -> &mut StatelessResponse<W>
The response end (ADR-005 §2’s response rules: one-shot flush,
no 0002, data-after-flush refused).
Sourcepub fn take_raw_tail(&mut self) -> Result<RawTail<R>, SubstrateError>
pub fn take_raw_tail(&mut self) -> Result<RawTail<R>, SubstrateError>
The raw-tail escape (ADR-013 §3; ADR-018 §4): after
StatelessRequest::read_post resolved a command invocation,
the pkt-line machinery surrenders the POST body’s remaining
bytes as a raw async reader (RawTail) — the pack follows the
command flush unframed inside the same body. The no-byte-loss
argument mirrors the duplex escape: the demand-driven iterator
reads with exact framing and clears its buffer at the stop, so
at surrender the body reader is positioned byte-exactly after
the terminating flush; the body-budget consumed counter rides
the tail for observability (the POST’s total reconciles).
Machinery misuse is refused, never silently re-entered:
- before a command-shaped parse (no
StatelessRequest::read_postyet, or the probe shape — a probe body has no tail) —SubstrateError::RawTailUnavailable, the reader stays in place; - after a terminal error — the cached terminal error;
- a second escape —
SubstrateError::RawTailUnavailable(the escape is one-shot); every laterStatelessRequest::read_poststays refused (one command invocation per POST).
Contract stamp: ADR-013 §3, ADR-020 §1, ADR-018 §4, ADR-005 §2, ADR-009 (the body-budget observability).
Sourcepub async fn read_post(&mut self) -> Result<StatelessPost, SubstrateError>
pub async fn read_post(&mut self) -> Result<StatelessPost, SubstrateError>
Reads the POST body as one command invocation (ADR-005 §2). The
request shape is the service’s (Service::UploadPack — the V2
command invocation; Service::ReceivePack — the V0-framed push
request, ADR-013 §3), and the parse rules — terminal failures,
the probe shape, the per-POST refusal — are service-shared.