trellis_client/descriptor.rs
1use serde::{de::DeserializeOwned, Serialize};
2
3/// Metadata required to call one typed Trellis RPC.
4pub trait RpcDescriptor {
5 /// Request payload type.
6 type Input: Serialize;
7
8 /// Success payload type.
9 type Output: DeserializeOwned;
10
11 /// Logical contract key for the RPC.
12 const KEY: &'static str;
13
14 /// Concrete NATS subject for the RPC.
15 const SUBJECT: &'static str;
16
17 /// Capability requirements declared for callers.
18 const CALLER_CAPABILITIES: &'static [&'static str];
19
20 /// Known error variants declared by the contract.
21 const ERRORS: &'static [&'static str];
22}
23
24/// Metadata required to publish one typed Trellis event.
25pub trait EventDescriptor {
26 /// Event payload type.
27 type Event: Serialize + DeserializeOwned;
28
29 /// Logical contract key for the event.
30 const KEY: &'static str;
31
32 /// Concrete NATS subject for the event.
33 const SUBJECT: &'static str;
34}