detritus_protocol/lib.rs
1#![cfg_attr(docsrs, feature(doc_cfg))]
2#![cfg_attr(all(test, coverage_nightly), feature(coverage_attribute))]
3//! Wire protocol types for Detritus telemetry and crash ingestion.
4//!
5//! `detritus-protocol` owns the schema shared by `detritus-client` and
6//! `detritus-server`: source identity, crash envelopes, and the curated OTLP
7//! log facade used by the client and receiver. Version `0.1.0` supports OTLP
8//! logs only; traces and metrics are intentionally outside the published
9//! compatibility surface.
10//!
11//! [`PROTOCOL_VERSION`] is carried in HTTP and gRPC metadata so clients and
12//! servers can reject payloads encoded for an incompatible schema.
13//!
14//! ```
15//! use detritus_protocol::PROTOCOL_VERSION;
16//!
17//! assert_eq!(PROTOCOL_VERSION, 1);
18//! ```
19//!
20//! # Features
21//!
22//! - **`multipart`** *(enabled by default)* — RFC 7578 multipart encoding and
23//! parsing of crash envelopes ([`multipart`]). Building with
24//! `default-features = false` drops it along with the `bytes`,
25//! `futures-util`, `multer`, and `tokio` dependencies, leaving the schema
26//! types for a logs-only consumer.
27
28/// Crash-report schema types and protocol errors.
29pub mod crash;
30#[cfg(feature = "multipart")]
31#[cfg_attr(docsrs, doc(cfg(feature = "multipart")))]
32/// Multipart encoding and parsing helpers for crash envelopes.
33pub mod multipart;
34/// Curated OpenTelemetry Protocol log-service bindings.
35pub mod otlp;
36/// Per-tenant JSON Schema descriptors for payload validation.
37pub mod schema;
38/// Source identity attached to Detritus payloads.
39pub mod source;
40
41/// Crash-report schema types re-exported for the common import path.
42pub use crash::{
43 AttachmentManifest, BuildInfo, CrashAttachment, CrashEnvelope, CrashKind, CrashMetadata,
44 ProtocolError,
45};
46/// Source identity re-exported for the common import path.
47pub use source::SourceId;
48
49/// Current observability ingestion schema version.
50pub const PROTOCOL_VERSION: u32 = 1;
51/// gRPC metadata key carrying [`PROTOCOL_VERSION`].
52pub const GRPC_VERSION_KEY: &str = "x-protocol-version";
53/// HTTP header carrying [`PROTOCOL_VERSION`].
54pub const HTTP_VERSION_HEADER: &str = "X-Protocol-Version";