nodedb_types/wire_version.rs
1// SPDX-License-Identifier: Apache-2.0
2
3//! Single source of truth for the `WIRE_FORMAT_VERSION` constant
4//! shared between every crate that needs to stamp or interpret it.
5//!
6//! This is the *cluster-wide* wire format version, distinct from:
7//! - `nodedb_cluster::wire::WIRE_VERSION` (the binary frame layout
8//! version of the `VShardEnvelope`),
9//! - the RPC frame header version in
10//! `nodedb_cluster::rpc_codec::header` (a private constant of that
11//! module).
12//!
13//! Bump this when the SPSC bridge, WAL, or RPC payload schemas change
14//! in a way that requires a coordinated upgrade. Readers MUST reject
15//! messages stamped with a version other than their own.
16
17/// Cluster-wide wire format version. Stamped on every `NodeInfo` and
18/// returned by `nodedb::version::WIRE_FORMAT_VERSION` (a re-export).
19pub const WIRE_FORMAT_VERSION: u16 = 4;
20
21/// Minimum wire format version this build can read. Equal to
22/// `WIRE_FORMAT_VERSION`: floor == ceiling, no backward compat window.
23pub const MIN_WIRE_FORMAT_VERSION: u16 = WIRE_FORMAT_VERSION;
24
25// Compile-time invariants — these constants must satisfy:
26// - MIN_WIRE_FORMAT_VERSION <= WIRE_FORMAT_VERSION
27// - WIRE_FORMAT_VERSION > 0
28const _: () = assert!(MIN_WIRE_FORMAT_VERSION <= WIRE_FORMAT_VERSION);
29const _: () = assert!(WIRE_FORMAT_VERSION > 0);