Skip to main content

zaun_community_protocol/envelope/
error_enums.rs

1//! Enumerated extra-field values of error bodies (§11).
2
3use serde::{Deserialize, Serialize};
4
5/// `FORBIDDEN` and `CONFLICT` reasons (§11).
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
7#[serde(rename_all = "snake_case")]
8pub enum Reason {
9    /// `FORBIDDEN`: a management-hierarchy check failed.
10    Hierarchy,
11    /// `FORBIDDEN`: newcomer restrictions (probation, waiting period).
12    Probation,
13    /// `FORBIDDEN`: an emergency lockdown restriction.
14    Lockdown,
15    /// `CONFLICT`: a `request_id` reused with another `type` or body (§7.3).
16    RequestIdReused,
17    /// `CONFLICT`: already a member.
18    AlreadyMember,
19    /// `CONFLICT`: the community is already hosted.
20    AlreadyHosted,
21    /// `CONFLICT`: the owner cannot leave.
22    OwnerCannotLeave,
23    /// `CONFLICT`: a signed object's revision is stale.
24    StaleRevision,
25    /// `CONFLICT`: the connection is already bound.
26    AlreadyBound,
27    /// `CONFLICT`: a count limit was reached.
28    LimitReached,
29    /// `CONFLICT`: the subject is in a state the command does not apply to (suspending a
30    /// `pending` member, restoring one that is not `suspended`, reviewing a closed report).
31    InvalidState,
32    /// `FORBIDDEN`: grants beyond the operator's ceiling or the manifest's request (§8.13).
33    Ceiling,
34    /// `FORBIDDEN`: a bot update signed by another publisher (§8.13).
35    Publisher,
36    /// `CONFLICT`: the bot's `app_id` is installed already (§8.13).
37    AlreadyInstalled,
38    /// `FORBIDDEN`: the member does not take direct messages from bots, or closed this one
39    /// (§8.15).
40    DmsClosed,
41}
42
43/// `RATE_LIMITED` scope (§11).
44#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
45#[serde(rename_all = "snake_case")]
46pub enum RateScope {
47    /// `connection`.
48    Connection,
49    /// `member`.
50    Member,
51    /// `invite`.
52    Invite,
53    /// `channel`.
54    Channel,
55    /// `community`.
56    Community,
57    /// `host`.
58    Host,
59}
60
61/// `RATE_LIMITED` category (§11).
62#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
63#[serde(rename_all = "snake_case")]
64pub enum RateCategory {
65    /// `commands`.
66    Commands,
67    /// `membership_request`.
68    MembershipRequest,
69    /// `invite_redeem`.
70    InviteRedeem,
71    /// `messages`.
72    Messages,
73    /// `attachments`.
74    Attachments,
75    /// `history`.
76    History,
77    /// `sync`.
78    Sync,
79    /// `reactions`.
80    Reactions,
81    /// `mentions`.
82    Mentions,
83    /// `voice`.
84    Voice,
85    /// `community_create`.
86    CommunityCreate,
87    /// `reports`.
88    Reports,
89    /// `dms`: opening direct messages, and a bot writing into one nobody answered (§8.15).
90    Dms,
91}