@@ -6,25 +6,7 @@ use crate::user::User;
66
77#[ async_trait:: async_trait]
88pub trait UserStore : Send + Sync {
9- async fn from_email ( & mut self , email : & str ) -> Option < User > ;
10- }
11-
12- #[ derive( Debug , Clone ) ]
13- pub enum UserStoreKind {
14- Static ( StaticUserStore ) ,
15- File ( FileUserStore ) ,
16- SQL ( SQLUserStore ) ,
17- }
18-
19- #[ async_trait:: async_trait]
20- impl UserStore for UserStoreKind {
21- async fn from_email ( & mut self , email : & str ) -> Option < User > {
22- match self {
23- UserStoreKind :: Static ( store) => store. from_email ( email) . await ,
24- UserStoreKind :: File ( store) => store. from_email ( email) . await ,
25- UserStoreKind :: SQL ( store) => store. from_email ( email) . await ,
26- }
27- }
9+ async fn from_email ( & self , email : & str ) -> Option < User > ;
2810}
2911
3012#[ derive( Debug , Clone , Serialize , Deserialize ) ]
@@ -38,7 +20,7 @@ impl StaticUserStore {
3820
3921#[ async_trait:: async_trait]
4022impl UserStore for StaticUserStore {
41- async fn from_email ( & mut self , email : & str ) -> Option < User > {
23+ async fn from_email ( & self , email : & str ) -> Option < User > {
4224 self . 0 . iter ( ) . find ( |user| user. email == email) . cloned ( )
4325 }
4426}
@@ -54,7 +36,7 @@ impl FileUserStore {
5436
5537#[ async_trait:: async_trait]
5638impl UserStore for FileUserStore {
57- async fn from_email ( & mut self , email : & str ) -> Option < User > {
39+ async fn from_email ( & self , email : & str ) -> Option < User > {
5840 let users_contents = match std:: fs:: read_to_string ( self . 0 . clone ( ) ) {
5941 Ok ( contents) => contents,
6042 Err ( e) => {
@@ -95,7 +77,7 @@ impl SQLUserStore {
9577
9678#[ async_trait:: async_trait]
9779impl UserStore for SQLUserStore {
98- async fn from_email ( & mut self , email : & str ) -> Option < User > {
80+ async fn from_email ( & self , email : & str ) -> Option < User > {
9981 // let Ok(conn) = self.conn.acquire().await else {
10082 // error!("Failed to acquire connection from the SQL user pool");
10183 // return None;
0 commit comments