zeeper/
lib.rs

1pub mod ghub;
2pub mod gtr;
3pub mod level;
4pub mod modio;
5pub mod playlist;
6pub mod zworpshop;
7
8pub use level::Level;
9pub use playlist::Playlist;
10
11use thiserror::Error;
12
13#[derive(Debug, Clone)]
14pub enum Id {
15    Steam(u64),
16    Discord(String),
17    Gtr(u32),
18}
19
20#[derive(Debug)]
21pub enum Query {
22    Gtr(String),
23    Zworpshop(String),
24}
25
26impl Query {
27    pub fn value(self) -> String {
28        match self {
29            Query::Gtr(s) => s,
30            Query::Zworpshop(s) => s,
31        }
32    }
33}
34
35#[derive(Error, Debug)]
36pub enum CmdErr {
37    #[error("this command requires an api key")]
38    NoApiKey,
39}
40
41#[macro_export]
42macro_rules! err {
43    // this is first to catch err!("message {a}") and work how youd expect
44    ($e:literal $(, $a:expr)*) => {
45        // brackets make it work as an expression
46        {
47            eprintln!("[{} {}:{}]", file!(), line!(), column!());
48            eprintln!($e $(,$a)*);
49        }
50    };
51    ($($e:expr),*) => {
52        {
53            eprintln!("[{} {}:{}]", file!(), line!(), column!());
54            $(
55            eprintln!("{}", $e);
56            )*
57        }
58    }
59}