Skip to main content

yog_event/
bus.rs

1//! The bus described: what each address carries, asked of the bus itself
2//! (services the runtime provides) — discovery, checking, bindings.
3
4use yog_data::{Schema, Value};
5
6/// What an address is.
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Schema)]
8pub enum AddressKind {
9    /// Emitted; anyone listens.
10    Event,
11    /// Called; one provider answers.
12    Service,
13}
14
15/// An address's descriptor.
16#[derive(Debug, Clone, PartialEq, Schema)]
17pub struct Descriptor {
18    pub address: String,
19    pub kind: AddressKind,
20    pub doc: String,
21    /// The payload's shape (`yog_data::Shape::describe`).
22    pub shape: Value,
23    /// A service's reply's shape.
24    pub reply: Option<Value>,
25    /// The interfaces it implements (`yog:energy/storage`): what [`Find`] finds it by.
26    #[data(default)]
27    pub interfaces: Vec<String>,
28}
29
30/// Every address under `prefix` (`pipes:`, `yog:event/player/`; empty: all).
31#[derive(Debug, Clone, Schema)]
32pub struct List {
33    pub prefix: String,
34}
35
36/// An address's descriptor.
37#[derive(Debug, Clone, Schema)]
38pub struct Describe {
39    pub address: String,
40}
41
42/// The addresses implementing `interface`.
43#[derive(Debug, Clone, Schema)]
44pub struct Find {
45    pub interface: String,
46}