1#[macro_use]
2extern crate serde;
3
4#[macro_use]
5extern crate async_recursion;
6
7#[macro_use]
8extern crate async_trait;
9
10#[macro_use]
11extern crate log;
12
13#[macro_use]
14extern crate revolt_optional_struct;
15
16#[macro_use]
17extern crate revolt_result;
18
19pub use iso8601_timestamp;
20
21#[cfg(feature = "mongodb")]
22pub use mongodb;
23
24#[cfg(feature = "mongodb")]
25#[macro_use]
26extern crate bson;
27
28#[macro_export]
29#[cfg(debug_assertions)]
30macro_rules! query {
31 ( $self: ident, $type: ident, $collection: expr, $($rest:expr),+ ) => {
32 Ok($self.$type($collection, $($rest),+).await.unwrap())
33 };
34}
35
36#[macro_export]
37#[cfg(not(debug_assertions))]
38macro_rules! query {
39 ( $self: ident, $type: ident, $collection: expr, $($rest:expr),+ ) => {
40 $self.$type($collection, $($rest),+).await
41 .map_err(|err| {
42 revolt_config::capture_internal_error!(err);
43 create_database_error!(stringify!($type), $collection)
44 })
45 };
46}
47
48macro_rules! database_derived {
49 ( $( $item:item )+ ) => {
50 $(
51 #[derive(Clone)]
52 $item
53 )+
54 };
55}
56
57macro_rules! auto_derived {
58 ( $( $item:item )+ ) => {
59 $(
60 #[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
61 $item
62 )+
63 };
64}
65
66macro_rules! auto_derived_partial {
67 ( $item:item, $name:expr ) => {
68 #[derive(OptionalStruct, Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
69 #[optional_derive(Serialize, Deserialize, Debug, Clone, Default, Eq, PartialEq)]
70 #[optional_name = $name]
71 #[opt_skip_serializing_none]
72 #[opt_some_priority]
73 $item
74 };
75}
76
77mod drivers;
78pub use drivers::*;
79
80#[cfg(test)]
81macro_rules! database_test {
82 ( | $db: ident | $test:expr ) => {
83 let db = $crate::DatabaseInfo::Test(format!(
84 "{}:{}",
85 file!().replace('/', "_").replace(".rs", ""),
86 line!()
87 ))
88 .connect()
89 .await
90 .expect("Database connection failed.");
91
92 db.drop_database().await;
93
94 #[allow(clippy::redundant_closure_call)]
95 (|$db: $crate::Database| $test)(db.clone()).await;
96
97 db.drop_database().await
98 };
99}
100
101mod models;
102pub mod util;
103pub use models::*;
104
105pub mod events;
106pub mod tasks;
107
108mod amqp;
109pub use amqp::amqp::AMQP;
110
111pub fn if_false(t: &bool) -> bool {
113 !t
114}
115
116pub fn if_option_false(t: &Option<bool>) -> bool {
118 t != &Some(true)
119}