22use std:: str:: FromStr ;
33use std:: time:: Duration ;
44
5- use async_trait:: async_trait;
65use r2d2:: Pool ;
76use r2d2_mysql:: mysql:: prelude:: Queryable ;
87use r2d2_mysql:: mysql:: { params, Opts , OptsBuilder } ;
@@ -22,7 +21,6 @@ pub struct Mysql {
2221 pool : Pool < MySqlConnectionManager > ,
2322}
2423
25- #[ async_trait]
2624impl Database for Mysql {
2725 /// It instantiates a new `MySQL` database driver.
2826 ///
@@ -106,7 +104,7 @@ impl Database for Mysql {
106104 }
107105
108106 /// 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 > {
110108 let mut conn = self . pool . get ( ) . map_err ( |e| ( e, DRIVER ) ) ?;
111109
112110 let torrents = conn. query_map (
@@ -121,7 +119,7 @@ impl Database for Mysql {
121119 }
122120
123121 /// 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 > {
125123 let mut conn = self . pool . get ( ) . map_err ( |e| ( e, DRIVER ) ) ?;
126124
127125 let keys = conn. query_map (
@@ -136,7 +134,7 @@ impl Database for Mysql {
136134 }
137135
138136 /// 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 > {
140138 let mut conn = self . pool . get ( ) . map_err ( |e| ( e, DRIVER ) ) ?;
141139
142140 let info_hashes = conn. query_map ( "SELECT info_hash FROM whitelist" , |info_hash : String | {
@@ -147,7 +145,7 @@ impl Database for Mysql {
147145 }
148146
149147 /// 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 > {
151149 const COMMAND : & str = "INSERT INTO torrents (info_hash, completed) VALUES (:info_hash_str, :completed) ON DUPLICATE KEY UPDATE completed = VALUES(completed)" ;
152150
153151 let mut conn = self . pool . get ( ) . map_err ( |e| ( e, DRIVER ) ) ?;
@@ -160,7 +158,7 @@ impl Database for Mysql {
160158 }
161159
162160 /// 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 > {
164162 let mut conn = self . pool . get ( ) . map_err ( |e| ( e, DRIVER ) ) ?;
165163
166164 let select = conn. exec_first :: < String , _ , _ > (
@@ -174,7 +172,7 @@ impl Database for Mysql {
174172 }
175173
176174 /// 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 > {
178176 let mut conn = self . pool . get ( ) . map_err ( |e| ( e, DRIVER ) ) ?;
179177
180178 let info_hash_str = info_hash. to_string ( ) ;
@@ -188,7 +186,7 @@ impl Database for Mysql {
188186 }
189187
190188 /// 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 > {
192190 let mut conn = self . pool . get ( ) . map_err ( |e| ( e, DRIVER ) ) ?;
193191
194192 let info_hash = info_hash. to_string ( ) ;
@@ -199,7 +197,7 @@ impl Database for Mysql {
199197 }
200198
201199 /// 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 > {
203201 let mut conn = self . pool . get ( ) . map_err ( |e| ( e, DRIVER ) ) ?;
204202
205203 let query = conn. exec_first :: < ( String , i64 ) , _ , _ > (
@@ -216,7 +214,7 @@ impl Database for Mysql {
216214 }
217215
218216 /// 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 > {
220218 let mut conn = self . pool . get ( ) . map_err ( |e| ( e, DRIVER ) ) ?;
221219
222220 let key = auth_key. key . to_string ( ) ;
@@ -231,7 +229,7 @@ impl Database for Mysql {
231229 }
232230
233231 /// 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 > {
235233 let mut conn = self . pool . get ( ) . map_err ( |e| ( e, DRIVER ) ) ?;
236234
237235 conn. exec_drop ( "DELETE FROM `keys` WHERE key = :key" , params ! { "key" => key. to_string( ) } ) ?;
0 commit comments