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