rosu_render/model/
verification.rs

1use std::fmt::{Debug, Formatter, Result as FmtResult};
2
3/// Specifying your verification key will allow you to bypass the default ratelimit of one render per five minutes.
4/// Alternatively, you can specify a dev mode to simulate events and not spam the real backend with requests while testing things.
5#[derive(Clone)]
6pub enum Verification {
7    /// Verification key assigned by the o!rdr dev. DM MasterIO#4588 on Discord to get one.
8    Key(Box<str>),
9    /// Simulates a request that will successfully render a video. Listen to the websocket to get the state of this fake render
10    /// (`render_added`, `render_progress` and `render_done` are emitted).
11    DevModeSuccess,
12    /// Simulates a request that will fail on the API level. No websocket events are emitted.
13    DevModeFail,
14    /// Simulates a request that will fail on the Websocket level (`render_failed` event is emitted).
15    DevModeWsFail,
16}
17
18impl Verification {
19    #[must_use]
20    pub fn as_str(&self) -> &str {
21        match self {
22            Self::Key(key) => key,
23            Self::DevModeSuccess => "devmode_success",
24            Self::DevModeFail => "devmode_fail",
25            Self::DevModeWsFail => "devmode_wsfail",
26        }
27    }
28}
29
30impl Debug for Verification {
31    fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
32        match self {
33            Self::Key(_) => f.debug_tuple("Key").field(&"<redacted>").finish(),
34            Self::DevModeSuccess => f.write_str("DevModeSuccess"),
35            Self::DevModeFail => f.write_str("DevModeFail"),
36            Self::DevModeWsFail => f.write_str("DevModeWsFail"),
37        }
38    }
39}