Skip to main content

subc_protocol/
session.rs

1//! Session route control wire contract.
2//!
3//! subc has two distinct channel-0 handshakes. Module registration is the
4//! module-to-subc `HELLO`/`HELLO_ACK` handshake that registers the manifest and
5//! liveness. Route bind is the client-to-subc-to-module request/response
6//! handshake that binds one client route to a module route channel.
7
8use serde::{Deserialize, Serialize};
9
10use crate::{BindIdentity, RouteTarget};
11
12/// subc-to-module channel-0 control RPC body.
13#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
14#[serde(tag = "op")]
15pub enum ModuleControlRequest {
16    #[serde(rename = "route.bind")]
17    RouteBind {
18        route_channel: u16,
19        target: RouteTarget,
20        identity: BindIdentity,
21    },
22}
23
24/// Module-to-subc channel-0 response body.
25#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
26#[serde(tag = "op")]
27pub enum ModuleControlResponse {
28    /// ACK-only success. Rejections use the `FrameType::Error` lane.
29    #[serde(rename = "route.bind")]
30    RouteBindAck {},
31}
32
33/// Module-to-subc channel-0 push body.
34#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
35#[serde(tag = "op")]
36pub enum ModuleControlPush {
37    #[serde(rename = "route.status")]
38    RouteStatus { route_channel: u16, status: String },
39}