2
2
use std:: str:: FromStr ;
3
3
use std:: time:: Duration ;
4
4
5
- use async_trait:: async_trait;
6
5
use r2d2:: Pool ;
7
6
use r2d2_mysql:: mysql:: prelude:: Queryable ;
8
7
use r2d2_mysql:: mysql:: { params, Opts , OptsBuilder } ;
@@ -22,7 +21,6 @@ pub struct Mysql {
22
21
pool : Pool < MySqlConnectionManager > ,
23
22
}
24
23
25
- #[ async_trait]
26
24
impl Database for Mysql {
27
25
/// It instantiates a new `MySQL` database driver.
28
26
///
@@ -106,7 +104,7 @@ impl Database for Mysql {
106
104
}
107
105
108
106
/// Refer to [`databases::Database::load_persistent_torrents`](crate::core::databases::Database::load_persistent_torrents).
109
- async fn load_persistent_torrents ( & self ) -> Result < PersistentTorrents , Error > {
107
+ fn load_persistent_torrents ( & self ) -> Result < PersistentTorrents , Error > {
110
108
let mut conn = self . pool . get ( ) . map_err ( |e| ( e, DRIVER ) ) ?;
111
109
112
110
let torrents = conn. query_map (
@@ -121,7 +119,7 @@ impl Database for Mysql {
121
119
}
122
120
123
121
/// Refer to [`databases::Database::load_keys`](crate::core::databases::Database::load_keys).
124
- async fn load_keys ( & self ) -> Result < Vec < auth:: ExpiringKey > , Error > {
122
+ fn load_keys ( & self ) -> Result < Vec < auth:: ExpiringKey > , Error > {
125
123
let mut conn = self . pool . get ( ) . map_err ( |e| ( e, DRIVER ) ) ?;
126
124
127
125
let keys = conn. query_map (
@@ -136,7 +134,7 @@ impl Database for Mysql {
136
134
}
137
135
138
136
/// Refer to [`databases::Database::load_whitelist`](crate::core::databases::Database::load_whitelist).
139
- async fn load_whitelist ( & self ) -> Result < Vec < InfoHash > , Error > {
137
+ fn load_whitelist ( & self ) -> Result < Vec < InfoHash > , Error > {
140
138
let mut conn = self . pool . get ( ) . map_err ( |e| ( e, DRIVER ) ) ?;
141
139
142
140
let info_hashes = conn. query_map ( "SELECT info_hash FROM whitelist" , |info_hash : String | {
@@ -147,7 +145,7 @@ impl Database for Mysql {
147
145
}
148
146
149
147
/// Refer to [`databases::Database::save_persistent_torrent`](crate::core::databases::Database::save_persistent_torrent).
150
- async fn save_persistent_torrent ( & self , info_hash : & InfoHash , completed : u32 ) -> Result < ( ) , Error > {
148
+ fn save_persistent_torrent ( & self , info_hash : & InfoHash , completed : u32 ) -> Result < ( ) , Error > {
151
149
const COMMAND : & str = "INSERT INTO torrents (info_hash, completed) VALUES (:info_hash_str, :completed) ON DUPLICATE KEY UPDATE completed = VALUES(completed)" ;
152
150
153
151
let mut conn = self . pool . get ( ) . map_err ( |e| ( e, DRIVER ) ) ?;
@@ -160,7 +158,7 @@ impl Database for Mysql {
160
158
}
161
159
162
160
/// Refer to [`databases::Database::get_info_hash_from_whitelist`](crate::core::databases::Database::get_info_hash_from_whitelist).
163
- async fn get_info_hash_from_whitelist ( & self , info_hash : & InfoHash ) -> Result < Option < InfoHash > , Error > {
161
+ fn get_info_hash_from_whitelist ( & self , info_hash : InfoHash ) -> Result < Option < InfoHash > , Error > {
164
162
let mut conn = self . pool . get ( ) . map_err ( |e| ( e, DRIVER ) ) ?;
165
163
166
164
let select = conn. exec_first :: < String , _ , _ > (
@@ -174,7 +172,7 @@ impl Database for Mysql {
174
172
}
175
173
176
174
/// Refer to [`databases::Database::add_info_hash_to_whitelist`](crate::core::databases::Database::add_info_hash_to_whitelist).
177
- async fn add_info_hash_to_whitelist ( & self , info_hash : InfoHash ) -> Result < usize , Error > {
175
+ fn add_info_hash_to_whitelist ( & self , info_hash : InfoHash ) -> Result < usize , Error > {
178
176
let mut conn = self . pool . get ( ) . map_err ( |e| ( e, DRIVER ) ) ?;
179
177
180
178
let info_hash_str = info_hash. to_string ( ) ;
@@ -188,7 +186,7 @@ impl Database for Mysql {
188
186
}
189
187
190
188
/// Refer to [`databases::Database::remove_info_hash_from_whitelist`](crate::core::databases::Database::remove_info_hash_from_whitelist).
191
- async fn remove_info_hash_from_whitelist ( & self , info_hash : InfoHash ) -> Result < usize , Error > {
189
+ fn remove_info_hash_from_whitelist ( & self , info_hash : InfoHash ) -> Result < usize , Error > {
192
190
let mut conn = self . pool . get ( ) . map_err ( |e| ( e, DRIVER ) ) ?;
193
191
194
192
let info_hash = info_hash. to_string ( ) ;
@@ -199,7 +197,7 @@ impl Database for Mysql {
199
197
}
200
198
201
199
/// Refer to [`databases::Database::get_key_from_keys`](crate::core::databases::Database::get_key_from_keys).
202
- async fn get_key_from_keys ( & self , key : & Key ) -> Result < Option < auth:: ExpiringKey > , Error > {
200
+ fn get_key_from_keys ( & self , key : & Key ) -> Result < Option < auth:: ExpiringKey > , Error > {
203
201
let mut conn = self . pool . get ( ) . map_err ( |e| ( e, DRIVER ) ) ?;
204
202
205
203
let query = conn. exec_first :: < ( String , i64 ) , _ , _ > (
@@ -216,7 +214,7 @@ impl Database for Mysql {
216
214
}
217
215
218
216
/// Refer to [`databases::Database::add_key_to_keys`](crate::core::databases::Database::add_key_to_keys).
219
- async fn add_key_to_keys ( & self , auth_key : & auth:: ExpiringKey ) -> Result < usize , Error > {
217
+ fn add_key_to_keys ( & self , auth_key : & auth:: ExpiringKey ) -> Result < usize , Error > {
220
218
let mut conn = self . pool . get ( ) . map_err ( |e| ( e, DRIVER ) ) ?;
221
219
222
220
let key = auth_key. key . to_string ( ) ;
@@ -231,7 +229,7 @@ impl Database for Mysql {
231
229
}
232
230
233
231
/// Refer to [`databases::Database::remove_key_from_keys`](crate::core::databases::Database::remove_key_from_keys).
234
- async fn remove_key_from_keys ( & self , key : & Key ) -> Result < usize , Error > {
232
+ fn remove_key_from_keys ( & self , key : & Key ) -> Result < usize , Error > {
235
233
let mut conn = self . pool . get ( ) . map_err ( |e| ( e, DRIVER ) ) ?;
236
234
237
235
conn. exec_drop ( "DELETE FROM `keys` WHERE key = :key" , params ! { "key" => key. to_string( ) } ) ?;
0 commit comments