Skip to main content

cortexfs_channels/
capability.rs

1use serde::{Deserialize, Serialize};
2
3/// Features that an adapter can expose without platform-specific branching.
4#[expect(
5    clippy::struct_excessive_bools,
6    reason = "independent capability flags are the stable serialized wire shape"
7)]
8#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
9pub struct ChannelCapabilities {
10    pub receive: bool,
11    pub send: bool,
12    pub threads: bool,
13    pub media: bool,
14    pub reactions: bool,
15    pub typing: bool,
16    pub webhook: bool,
17}
18
19impl ChannelCapabilities {
20    #[must_use]
21    pub const fn text() -> Self {
22        Self {
23            receive: true,
24            send: true,
25            ..Self::empty()
26        }
27    }
28
29    #[must_use]
30    pub const fn empty() -> Self {
31        Self {
32            receive: false,
33            send: false,
34            threads: false,
35            media: false,
36            reactions: false,
37            typing: false,
38            webhook: false,
39        }
40    }
41}
42
43/// Liveness of one adapter, separate from capability discovery.
44#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
45pub enum HealthState {
46    Ready,
47    Degraded,
48    Unavailable,
49}
50
51/// Health result that can be surfaced without leaking credentials.
52#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
53pub struct ChannelHealth {
54    pub state: HealthState,
55    pub detail: Option<String>,
56}
57
58impl ChannelHealth {
59    #[must_use]
60    pub const fn ready() -> Self {
61        Self {
62            state: HealthState::Ready,
63            detail: None,
64        }
65    }
66}