Skip to main content

muse_code_sdk/msp/method/
usage.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use serde::Deserialize;
4use serde::Serialize;
5
6/// The current usage window (the provider's 5-hour-class block): verbatim
7/// provider percentages with the reset stamp normalized to epoch milliseconds.
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
9#[serde(rename_all = "camelCase")]
10#[non_exhaustive]
11pub struct SubscriptionUsageWindow {
12    /// Percent of the window's budget used: an integer ≥ 0, verbatim from
13    /// the provider — over-quota values above 100 are valid.
14    pub used_percent: i64,
15    /// The window's length in minutes (> 0).
16    pub window_duration_mins: i64,
17    /// When the window resets, epoch milliseconds.
18    pub resets_at_ms: i64,
19}
20
21/// The rolling weekly block: same semantics as [`SubscriptionUsageWindow`]
22/// without a duration.
23#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
24#[serde(rename_all = "camelCase")]
25#[non_exhaustive]
26pub struct SubscriptionUsageWeekly {
27    /// Percent of the weekly budget used (integer ≥ 0, may exceed 100).
28    pub used_percent: i64,
29    /// When the weekly window resets, epoch milliseconds.
30    pub resets_at_ms: i64,
31}
32
33/// The one usage payload shape: the `usage/read` result's `usage` member and
34/// the `usage/changed` params. The numbers are point-in-time — `observedAtMs`
35/// is the host's arrival stamp, so a client renders "as of", never implies live
36/// data.
37#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
38#[serde(rename_all = "camelCase")]
39#[non_exhaustive]
40pub struct SubscriptionUsage {
41    /// The current window.
42    pub window: SubscriptionUsageWindow,
43    /// The rolling weekly block.
44    pub weekly: SubscriptionUsageWeekly,
45    /// The provider's subscription tier id, verbatim.
46    pub tier: String,
47    /// When the host RECEIVED this observation (frame arrival or mint
48    /// request-send), epoch milliseconds.
49    pub observed_at_ms: i64,
50}
51
52/// `usage/read` result: `{usage?}` — omitted, never `null`, when the host has
53/// observed nothing.
54#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
55#[serde(rename_all = "camelCase")]
56#[non_exhaustive]
57pub struct UsageReadResult {
58    /// The last-observed subscription usage window, when one exists.
59    #[serde(skip_serializing_if = "Option::is_none")]
60    pub usage: Option<SubscriptionUsage>,
61}