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, Principal, 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        #[serde(default, skip_serializing_if = "Option::is_none")]
22        principal: Option<Principal>,
23    },
24}
25
26/// Module-to-subc channel-0 response body.
27#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
28#[serde(tag = "op")]
29pub enum ModuleControlResponse {
30    /// ACK-only success. Rejections use the `FrameType::Error` lane.
31    #[serde(rename = "route.bind")]
32    RouteBindAck {},
33}
34
35/// Module-to-subc channel-0 push body.
36#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
37#[serde(tag = "op")]
38pub enum ModuleControlPush {
39    #[serde(rename = "route.status")]
40    RouteStatus { route_channel: u16, status: String },
41}