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#[cfg(not(feature = "async-std-runtime"))]
29compile_error!("async-std-runtime feature must be enabled.");
30
31#[macro_export]
32#[cfg(debug_assertions)]
33macro_rules! query {
34 ( $self: ident, $type: ident, $collection: expr, $($rest:expr),+ ) => {
35 Ok($self.$type($collection, $($rest),+).await.unwrap())
36 };
37}
38
39#[macro_export]
40#[cfg(not(debug_assertions))]
41macro_rules! query {
42 ( $self: ident, $type: ident, $collection: expr, $($rest:expr),+ ) => {
43 $self.$type($collection, $($rest),+).await
44 .map_err(|err| {
45 revolt_config::capture_internal_error!(err);
46 create_database_error!(stringify!($type), $collection)
47 })
48 };
49}
50
51macro_rules! database_derived {
52 ( $( $item:item )+ ) => {
53 $(
54 #[derive(Clone)]
55 $item
56 )+
57 };
58}
59
60macro_rules! auto_derived {
61 ( $( $item:item )+ ) => {
62 $(
63 #[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
64 $item
65 )+
66 };
67}
68
69macro_rules! auto_derived_partial {
70 ( $item:item, $name:expr ) => {
71 #[derive(OptionalStruct, Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
72 #[optional_derive(Serialize, Deserialize, Debug, Clone, Default, Eq, PartialEq)]
73 #[optional_name = $name]
74 #[opt_skip_serializing_none]
75 #[opt_some_priority]
76 $item
77 };
78}
79
80mod drivers;
81pub use drivers::*;
82
83#[cfg(test)]
84macro_rules! database_test {
85 ( | $db: ident | $test:expr ) => {
86 let db = $crate::DatabaseInfo::Test(format!(
87 "{}:{}",
88 file!().replace('/', "_").replace(".rs", ""),
89 line!()
90 ))
91 .connect()
92 .await
93 .expect("Database connection failed.");
94
95 db.drop_database().await;
96
97 #[allow(clippy::redundant_closure_call)]
98 (|$db: $crate::Database| $test)(db.clone()).await;
99
100 db.drop_database().await
101 };
102}
103
104mod models;
105pub mod util;
106pub use models::*;
107
108pub mod events;
109#[cfg(feature = "tasks")]
110pub mod tasks;
111
112mod amqp;
113pub use amqp::amqp::AMQP;
114
115#[cfg(feature = "voice")]
116pub mod voice;
117
118
119pub fn if_false(t: &bool) -> bool {
121 !t
122}
123
124pub fn if_option_false(t: &Option<bool>) -> bool {
126 t != &Some(true)
127}