diff options
Diffstat (limited to 'src/users.rs')
-rw-r--r-- | src/users.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/users.rs b/src/users.rs index edc3c13fe3b1..0c93b83ec1da 100644 --- a/src/users.rs +++ b/src/users.rs @@ -1,7 +1,7 @@ //! A users abstraction module use crate::{ - wire::{User, UserId}, + wire::{LobbyErr, User, UserId}, Id, }; use async_std::sync::{Arc, RwLock}; @@ -31,6 +31,14 @@ impl UserStore { } } + /// Get the metadata user for a login user + pub async fn get(&self, user: &User) -> Result<Arc<MetaUser>, LobbyErr> { + match self.users.read().await.get(&user.id) { + Some(ref u) => Ok(Arc::clone(u)), + None => Err(LobbyErr::OtherError), + } + } + pub async fn add<S: Into<Option<String>>>( &self, name: String, |