pub trait SchemaValidate {
// Required method
fn schema_metadata() -> SchemaMetadata;
}Expand description
Compile-time marker for message types that declare schema metadata.
Publishing methods require this trait in addition to serde::Serialize.
That bound ensures a type that is merely serializable cannot be published to
a typed liminal channel unless it also declares the schema metadata needed by
the bus for publish-time validation.
Implement the trait manually today:
use liminal_sdk::{SchemaMetadata, SchemaValidate};
use serde::Serialize;
#[derive(Serialize)]
struct Created {
id: String,
}
impl SchemaValidate for Created {
fn schema_metadata() -> SchemaMetadata {
SchemaMetadata::new(
"example.created",
"1",
br#"{"type":"object","required":["id"]}"#.as_slice(),
)
}
}A future #[derive(SchemaValidate)] macro is expected to generate this same
implementation for supported schema-generation workflows. This crate does
not provide a blanket implementation for all serializable types because doing
so would remove the compile-time enforcement required by typed channels.
Required Methods§
Sourcefn schema_metadata() -> SchemaMetadata
fn schema_metadata() -> SchemaMetadata
Returns this message type’s schema metadata.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".