1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use Cow;
/// Schema metadata supplied by user-defined message types.
///
/// The SDK uses this metadata to let concrete channel implementations validate
/// outbound payloads against the channel's declared type. The trait that returns
/// this value is intentionally metadata-only: it does not parse schemas or run
/// validation itself.
/// 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.