Skip to main content

noxy_sdk/
types.rs

1//! Type definitions matching `agent.proto` and the SDK API.
2
3/// EVM wallet address in 0x format.
4pub type NoxyIdentityAddress = String;
5
6/// Relay-side delivery status after `RouteDecision` (matches proto `DeliveryStatus`).
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8#[repr(i32)]
9pub enum NoxyDeliveryStatus {
10    Delivered = 0,
11    Queued = 1,
12    NoDevices = 2,
13    Rejected = 3,
14    Error = 4,
15}
16
17impl From<i32> for NoxyDeliveryStatus {
18    fn from(v: i32) -> Self {
19        match v {
20            0 => Self::Delivered,
21            1 => Self::Queued,
22            2 => Self::NoDevices,
23            3 => Self::Rejected,
24            4 => Self::Error,
25            _ => Self::Error,
26        }
27    }
28}
29
30/// Response for a single `RouteDecision` delivery to one device.
31#[derive(Debug, Clone)]
32pub struct NoxyDeliveryOutcome {
33    pub status: NoxyDeliveryStatus,
34    pub request_id: String,
35    /// Present when the relay tracks human resolution; use with `get_decision_outcome` / `wait_for_decision_outcome`.
36    pub decision_id: String,
37}
38
39/// Human-in-the-loop resolution (matches proto `DecisionOutcome`).
40#[derive(Debug, Clone, Copy, PartialEq, Eq)]
41#[repr(i32)]
42pub enum NoxyHumanDecisionOutcome {
43    Pending = 0,
44    Approved = 1,
45    Rejected = 2,
46    Expired = 3,
47}
48
49impl From<i32> for NoxyHumanDecisionOutcome {
50    fn from(v: i32) -> Self {
51        match v {
52            0 => Self::Pending,
53            1 => Self::Approved,
54            2 => Self::Rejected,
55            3 => Self::Expired,
56            _ => Self::Pending,
57        }
58    }
59}
60
61/// Result of polling `GetDecisionOutcome`.
62#[derive(Debug, Clone)]
63pub struct NoxyGetDecisionOutcomeResponse {
64    pub request_id: String,
65    pub pending: bool,
66    pub outcome: NoxyHumanDecisionOutcome,
67}
68
69/// Quota status for the application.
70#[derive(Debug, Clone, Copy, PartialEq, Eq)]
71#[repr(i32)]
72pub enum NoxyQuotaStatus {
73    QuotaActive = 0,
74    QuotaSuspended = 1,
75    QuotaDeleted = 2,
76}
77
78impl From<i32> for NoxyQuotaStatus {
79    fn from(v: i32) -> Self {
80        match v {
81            0 => Self::QuotaActive,
82            1 => Self::QuotaSuspended,
83            2 => Self::QuotaDeleted,
84            _ => Self::QuotaActive,
85        }
86    }
87}
88
89/// Response for quota query.
90#[derive(Debug, Clone)]
91pub struct NoxyGetQuotaResponse {
92    pub request_id: String,
93    pub app_name: String,
94    pub quota_total: u64,
95    pub quota_remaining: u64,
96    pub status: NoxyQuotaStatus,
97}
98
99/// Identity device with keys for encryption.
100#[derive(Debug, Clone)]
101pub struct NoxyIdentityDevice {
102    pub device_id: String,
103    pub public_key: Vec<u8>,
104    pub pq_public_key: Vec<u8>,
105}