pub trait ContractBody:
Serialize
+ DeserializeOwned
+ Clone
+ Send
+ Sync
+ 'static {
type Api: ApiVersion;
const FAMILY: &'static str;
const TOPIC: &'static str;
}Expand description
The contract primitive traits, re-exported from the phoxal-bus crate (the
ABI floor) so they stay addressable at phoxal_api::ApiVersion /
phoxal_api::ContractBody.
ApiVersionis the marker trait identifying one dated API version (D60), implemented only by the zero-variantenum Api {}thatphoxal_api_tree!generates inside each version module; itsIDis the dated module name ("y2026_1") and the canonical version identity, carried in bus metadata.ContractBodyis a version-local wire body (D61): a plain serde type bound to exactly oneApiVersionand one contract family/topic. Every body declared inside aphoxal_api_tree!node gets a generated impl; handles,SetupContextbuilders, and the#[derive(Runtime)]assertions key off itsApi/FAMILY/TOPICto reject a body from the wrong API version at compile time. Its serde encoding is the wire payload; there is no version envelope (D62). A version-local wire body: a plain serde type bound to exactly oneApiVersionand one contract family/topic (D61).
Every body declared inside a phoxal_api_tree! node gets a generated impl.
Handles, SetupContext builders, and the #[derive(Runtime)] assertions all
key off Api/FAMILY/TOPIC,
which is how a body from the wrong API version is rejected at compile time.
The serde encoding of an implementor is the wire payload; there is no version
envelope (D62). Version and family travel as bus metadata, derived from
Api and FAMILY.
Required Associated Constants§
Sourceconst FAMILY: &'static str
const FAMILY: &'static str
Canonical contract family id: the ::-joined node path plus the body type
name, with dynamic variables excluded, e.g. "drive::State" or
"component::motor::Command".
Sourceconst TOPIC: &'static str
const TOPIC: &'static str
Versionless topic key: the /-joined node path plus the topic leaf, with
each dynamic node contributing a {var} placeholder, e.g. "drive/state"
or "component/{instance}/motor/{capability}/command". The runtime key is
produced by the api-local topic builder, which fills the placeholders.
Required Associated Types§
Sourcetype Api: ApiVersion
type Api: ApiVersion
The single API version this body belongs to. Two bodies from different
versions have different Api, so the type system keeps them apart.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".