Skip to main content

cratestack_axum/transport/
mod.rs

1//! Transport-level abstractions: the [`HttpTransport`] trait, transport
2//! header validation, the `encode_transport_*` and
3//! `encode_transport_sequence_*` response-encoding families, and the
4//! shared media-type helpers they rely on.
5
6mod encode_sequence;
7mod encode_unary;
8mod http_transport;
9mod internal;
10mod media_type;
11mod stream_sequence;
12pub(crate) use stream_sequence::encode_error_sentinel;
13mod validate;
14
15pub const CBOR_SEQUENCE_CONTENT_TYPE: &str = "application/cbor-seq";
16
17/// Marker inserted into `Response::extensions()` (never `headers()`) by
18/// genuinely incrementally-streamed `application/cbor-seq` responses
19/// (`@stream` procedures, via
20/// [`stream_sequence::encode_cbor_sequence_stream_response`] —
21/// cratestack#283), so response-buffering middleware (currently just
22/// [`crate::idempotency::IdempotencyService`]) can distinguish a truly
23/// incremental body from an ordinary buffered one and bypass buffering
24/// instead of silently re-collecting a partial stream. See
25/// `crate::idempotency::service` for the consumer.
26///
27/// Deliberately an extension, not a header: an extension is an in-process
28/// `http::Extensions` type-map entry on the `Response` struct — it has no
29/// wire representation at all, by construction, so there is no code path
30/// (missed strip step, a route with no idempotency middleware in front of
31/// it, ...) through which this could ever reach a real client. A header
32/// carrying the same "internal-only" intent would need every exit path
33/// to remember to strip it; this needs none of them to.
34#[derive(Clone, Copy)]
35pub(crate) struct StreamedResponseMarker;
36
37pub use encode_sequence::{
38    encode_transport_sequence_result, encode_transport_sequence_result_with_status,
39    encode_transport_sequence_result_with_status_for,
40    encode_transport_stream_result_with_status_for,
41};
42pub use encode_unary::{
43    encode_transport_result, encode_transport_result_with_status,
44    encode_transport_result_with_status_for,
45};
46pub use http_transport::HttpTransport;
47pub use validate::{
48    decode_transport_request_for, validate_transport_request_headers,
49    validate_transport_request_headers_for, validate_transport_response_headers,
50    validate_transport_response_headers_for,
51};
52
53pub(crate) use http_transport::CborCodecMarker;
54pub(crate) use internal::{encode_cbor_sequence_response, fallback_error_response};
55pub(crate) use media_type::{
56    select_transport_response_content_type, validate_transport_accept_header,
57    validate_transport_content_type_header,
58};
59pub(crate) use stream_sequence::encode_cbor_sequence_stream_response;