bakbon/message/mod.rs
1//! Message primitives for BakBon.
2//!
3//! This module defines the core message types used inside the system:
4//!
5//! - [`Envelope`] represents an application-level message with `Payload`
6//! and routing metadata.
7//! - [Headers] is a map of string key/value pairs attached to an
8//! [`Envelope`].
9//! - [Reply] models a optional reply message returned by
10//! [`Processor`](crate::Processor)
11//!
12//! High level components such as [`Gateway`](crate::Gateway),
13//! [`Service`](crate::Service), [`Router`](crate::Router) build on top of
14//! these primitives to exchange data between each other.
15
16mod envelope;
17mod route;
18
19pub use envelope::Envelope;
20use {
21 bytes::Bytes,
22 std::collections::HashMap,
23};
24
25/// Message metadata attached to an [`Envelope`](super::Envelope)
26///
27/// `Headers` are arbitrary key/value pairs. Some examples include:
28/// - `content-type`
29/// - `encoding`
30/// - `x-correlation-id`
31pub type Headers = HashMap<String, String>;
32
33/// Optional reply message returned by a [`Processor`](crate::Processor)
34pub type Reply = Option<Envelope>;
35
36/// Message payload attached to an [`Envelope`](super::Envelope)
37pub type Payload = Bytes;