dspk_stream/protocol/mod.rs
1//! The wire protocol (no networking): message types generated from `proto/dspk_stream.proto`,
2//! length-prefixed framing, and conversions to and from dspk-core / dspk-view types.
3//!
4//! See the `.proto` file for the session layout (control, signal and view streams).
5
6pub mod codec;
7pub mod convert;
8
9/// Messages generated from `proto/dspk_stream.proto` (package `dspk_stream.v1`).
10pub mod wire {
11 include!(concat!(env!("OUT_DIR"), "/dspk_stream.v1.rs"));
12}
13
14/// Protocol version sent in `ClientHello` and `ServerInfo`; peers of another version are refused.
15pub const PROTOCOL_VERSION: u32 = 2;
16
17/// TLS application protocol (ALPN): names the protocol and its version, so QUIC refuses peers
18/// speaking another one before any message is exchanged.
19pub const ALPN: &[u8] = b"dspk-stream/2";
20
21/// Bytes of the big-endian length before every message.
22pub const LENGTH_PREFIX_BYTES: usize = 4;
23
24/// Default upper bound on one encoded message (64 MiB); larger lengths are rejected before
25/// allocating.
26pub const DEFAULT_MAX_MESSAGE_BYTES: usize = 64 << 20;
27
28pub use codec::{read_message, write_message};
29pub use convert::{decode_signal, envelope_from_frame, frame_from_envelope, header_from_info, info_from_header, request_from_view, view_from_request};