reliar_core/lib.rs
1//! `reliar-core` is the pure envelope/message model every Reliar crate builds on: identity
2//! newtypes, the [`Message`] contract, a validated [`Headers`] map, typed [`Metadata`], and the
3//! [`Envelope`]/[`SerializedEnvelope`] pair that carries them (SRS §9–§17).
4//!
5//! # Guarantees
6//!
7//! - **Pure.** No storage or transport dependency: no sqlx, no broker client, no routing
8//! concept (a Kafka partition key, a `RabbitMQ` exchange, a NATS subject). Every other Reliar
9//! crate depends on this one; this one depends on nothing Reliar-specific (ADR 0002).
10//! - **One source of truth for framework metadata.** [`Envelope::metadata`] is canonical for
11//! every concept Reliar understands. A value here is never duplicated into
12//! [`Envelope::headers`], and Reliar never reads a framework value back out of headers
13//! (ADR 0004). [`Headers`] reserves the entire `reliar-` prefix, case-insensitively, so a
14//! custom header can never collide with — or be mistaken for — a framework one.
15//! - **Message identity never depends on `std::any::type_name::<T>()` or a module path.** A
16//! [`Message`]'s [`MessageType`] comes from its own `TYPE`/`VERSION` constants, so renaming or
17//! moving the Rust type is safe and two distinct types sharing them render identically
18//! (ADR 0010).
19//! - **One envelope type for both sides of a serialization boundary.** [`Envelope<T>`] and
20//! [`SerializedEnvelope`] (`= Envelope<bytes::Bytes>`) are the same generic type; converting
21//! between them ([`Envelope::map_body`]) can never drop or duplicate a field (ADR 0003).
22//!
23//! - **Owns vocabulary every capability shares, nothing storage/transport-specific.** An item
24//! belongs here when it names no storage engine, broker or transport routing concept *and* more
25//! than one Reliar capability needs it to talk to another — never merely because it is small
26//! (ADR 0032).
27//!
28//! Every public error is a hand-rolled, `#[non_exhaustive]` enum with a wired
29//! [`std::error::Error::source`] — no `thiserror`, no `anyhow`. `Debug` on payload-bearing types
30//! elides the bytes; no `Display` here ever prints a payload, a header value, or a credential.
31
32#![forbid(unsafe_code)]
33#![warn(missing_docs)]
34
35mod content_type;
36mod envelope;
37mod failure;
38mod headers;
39mod ids;
40mod mapper;
41mod message;
42mod metadata;
43mod publisher;
44mod serializer;
45mod settings;
46
47pub use content_type::{ContentType, ContentTypeError};
48pub use envelope::{Envelope, EnvelopeBuilder, SerializedEnvelope};
49pub use failure::{Classify, FailureKind};
50pub use headers::{HeaderError, Headers};
51pub use ids::{ConversationId, CorrelationId, IdError, MessageId, RequestId};
52pub use mapper::EnvelopeMapper;
53pub use message::{Message, MessageType};
54pub use metadata::{
55 CorrelationMetadata, DeliveryMetadata, EndpointAddress, Metadata, RoutingMetadata, TraceContext,
56};
57pub use publisher::Publisher;
58pub use serializer::Serializer;
59pub use settings::SettingsError;
60
61#[cfg(feature = "json")]
62pub use serializer::{JsonError, JsonSerializer};