diff options
author | 2025-04-11 00:49:36 +0100 | |
---|---|---|
committer | 2025-04-11 00:49:36 +0100 | |
commit | aab4cd47b1d2da5539c50675be4c7a36898189ef (patch) | |
tree | 3338bab6b08a076c8b39e8c3cb06a22f40a66e04 /filamento/src/lib.rs | |
parent | af7a0f5022dfd0e04c821f0d4fc8314b3578417c (diff) | |
download | luz-aab4cd47b1d2da5539c50675be4c7a36898189ef.tar.gz luz-aab4cd47b1d2da5539c50675be4c7a36898189ef.tar.bz2 luz-aab4cd47b1d2da5539c50675be4c7a36898189ef.zip |
feat(filamento): `get_roster_with_users()`
Diffstat (limited to 'filamento/src/lib.rs')
-rw-r--r-- | filamento/src/lib.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/filamento/src/lib.rs b/filamento/src/lib.rs index 7946241..9fa254e 100644 --- a/filamento/src/lib.rs +++ b/filamento/src/lib.rs @@ -52,6 +52,8 @@ pub mod user; pub enum Command<Fs: FileStore> { /// get the roster. if offline, retreive cached version from database. should be stored in application memory GetRoster(oneshot::Sender<Result<Vec<Contact>, RosterError>>), + /// get the roster. if offline, retreive cached version from database. should be stored in application memory. includes user associated with each contact + GetRosterWithUsers(oneshot::Sender<Result<Vec<(Contact, User)>, RosterError>>), /// get all chats. chat will include 10 messages in their message Vec (enough for chat previews) // TODO: paging and filtering GetChats(oneshot::Sender<Result<Vec<Chat>, DatabaseError>>), @@ -276,6 +278,22 @@ impl<Fs: FileStore> Client<Fs> { Ok(roster) } + pub async fn get_roster_with_users( + &self, + ) -> Result<Vec<(Contact, User)>, CommandError<RosterError>> { + let (send, recv) = oneshot::channel(); + self.send(CoreClientCommand::Command(Command::GetRosterWithUsers( + send, + ))) + .await + .map_err(|e| CommandError::Actor(Into::<ActorError>::into(e)))?; + let roster = timeout(self.timeout, recv) + .await + .map_err(|e| CommandError::Actor(Into::<ActorError>::into(e)))? + .map_err(|e| CommandError::Actor(Into::<ActorError>::into(e)))??; + Ok(roster) + } + pub async fn get_chats(&self) -> Result<Vec<Chat>, CommandError<DatabaseError>> { let (send, recv) = oneshot::channel(); self.send(CoreClientCommand::Command(Command::GetChats(send))) |