pub trait Message: Serialize + DeserializeOwned {
const TYPE: &'static str;
const VERSION: u16;
}Expand description
A type that can be built into an Envelope and persisted or published.
TYPE/VERSION are stable application contracts: they identify a message across
serialization, storage and the wire, and are never derived from
std::any::type_name::<T>() or a module path — renaming or moving the Rust type must not
orphan a pending row or a message already in flight (ADR 0010).
use reliar_core::Message;
#[derive(serde::Serialize, serde::Deserialize)]
struct OrderCancelled {
order_id: u64,
}
impl Message for OrderCancelled {
const TYPE: &'static str = "orders.cancelled";
const VERSION: u16 = 1;
}
assert_eq!(OrderCancelled::TYPE, "orders.cancelled");
assert_eq!(OrderCancelled::VERSION, 1);Required Associated Constants§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".