Skip to main content

seher/codexbar/
types.rs

1//! Deserialization types for the `codexbar usage --format json` payload.
2//!
3//! Mirrors `seher-ts/packages/sdk/src/codexbar/types.ts`. Unknown fields are
4//! ignored so the structs stay forward-compatible with new codexbar releases.
5
6use serde::Deserialize;
7
8#[derive(Debug, Clone, Deserialize)]
9#[serde(rename_all = "camelCase")]
10pub struct CodexBarWindow {
11    #[serde(default)]
12    pub used_percent: f64,
13    #[serde(default)]
14    pub window_minutes: Option<f64>,
15    #[serde(default)]
16    pub resets_at: Option<String>,
17    #[serde(default)]
18    pub reset_description: Option<String>,
19    #[serde(default)]
20    pub next_regen_percent: Option<f64>,
21}
22
23#[derive(Debug, Clone, Deserialize)]
24pub struct NamedCodexBarWindow {
25    #[serde(default)]
26    pub id: String,
27    #[serde(default)]
28    pub title: String,
29    pub window: CodexBarWindow,
30}
31
32#[derive(Debug, Clone, Default, Deserialize)]
33#[serde(rename_all = "camelCase")]
34pub struct CodexBarUsage {
35    #[serde(default)]
36    pub primary: Option<CodexBarWindow>,
37    #[serde(default)]
38    pub secondary: Option<CodexBarWindow>,
39    #[serde(default)]
40    pub tertiary: Option<CodexBarWindow>,
41    #[serde(default)]
42    pub extra_rate_windows: Option<Vec<NamedCodexBarWindow>>,
43}
44
45#[derive(Debug, Clone, Deserialize)]
46pub struct CodexBarUsageResponse {
47    pub provider: String,
48    #[serde(default)]
49    pub usage: CodexBarUsage,
50}