// file: kb-app-demo-desktop/src/demo_transport.rs // version: 1 //! UI-safe transport DTOs shared by HTTP and WebSocket demo surfaces. use ts_rs::TS; // rust-rules: derive-import /// UI-safe endpoint role and local routing limits. #[derive(Clone, Debug, serde::Serialize, TS)] #[serde(rename_all = "camelCase")] #[ts( export, export_to = "../frontend/ts/bindings/kb_app_demo_desktop/demo_transport/DemoEndpointRolePayload.ts" )] pub(crate) struct DemoEndpointRolePayload { /// Role code used by endpoint pools. pub(crate) role: std::string::String, /// Whether the role is enabled. pub(crate) enabled: bool, /// Request or subscription kinds handled by this role. pub(crate) request_kinds: std::vec::Vec, /// Role priority where lower values are preferred. pub(crate) priority: u32, /// Requests per second allowed for this role. pub(crate) requests_per_second: u32, /// Burst capacity allowed for this role. pub(crate) burst_capacity: u32, /// Maximum concurrent requests allowed for this role. pub(crate) max_concurrent_requests: u32, /// Maximum subscriptions allowed for this role. pub(crate) max_subscriptions: u32, /// Pause after a rate limit response in milliseconds. #[ts(type = "number")] pub(crate) pause_after_rate_limit_ms: u64, } impl crate::DemoEndpointRolePayload { /// Converts one backend transport role snapshot into the UI-safe application contract. pub(crate) fn from_snapshot(snapshot: ks_onchain_transport::EndpointRoleSnapshot) -> Self { return Self { role: snapshot.role, enabled: snapshot.enabled, request_kinds: snapshot.request_kinds, priority: snapshot.priority, requests_per_second: snapshot.requests_per_second, burst_capacity: snapshot.burst_capacity, max_concurrent_requests: snapshot.max_concurrent_requests, max_subscriptions: snapshot.max_subscriptions, pause_after_rate_limit_ms: snapshot.pause_after_rate_limit_ms, }; } }