diff options
Diffstat (limited to 'filamento/src/lib.rs')
-rw-r--r-- | filamento/src/lib.rs | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/filamento/src/lib.rs b/filamento/src/lib.rs index ed33e99..4d852e2 100644 --- a/filamento/src/lib.rs +++ b/filamento/src/lib.rs @@ -9,7 +9,7 @@ use std::{ use chat::{Body, Chat, Message}; use chrono::Utc; use db::Db; -use disco::Info; +use disco::{Info, Items}; use error::{ ConnectionJobError, DatabaseError, DiscoError, Error, IqError, MessageRecvError, PresenceError, RosterError, StatusError, @@ -102,10 +102,15 @@ pub enum Command { /// disco info query DiscoInfo( Option<JID>, + Option<String>, oneshot::Sender<Result<disco::Info, DiscoError>>, ), - // /// disco items query - // DiscoItems(JID, oneshot::Sender<Result<disco::Info, DiscoError>>), + /// disco items query + DiscoItems( + Option<JID>, + Option<String>, + oneshot::Sender<Result<disco::Items, DiscoError>>, + ), } #[derive(Debug, Clone)] @@ -480,11 +485,35 @@ impl Client { Ok(result) } - pub async fn disco_info(&self, jid: Option<JID>) -> Result<Info, CommandError<DiscoError>> { + pub async fn disco_info( + &self, + jid: Option<JID>, + node: Option<String>, + ) -> Result<Info, CommandError<DiscoError>> { let (send, recv) = oneshot::channel(); - self.send(CoreClientCommand::Command(Command::DiscoInfo(jid, send))) + self.send(CoreClientCommand::Command(Command::DiscoInfo( + jid, node, send, + ))) + .await + .map_err(|e| CommandError::Actor(Into::<ActorError>::into(e)))?; + let result = timeout(self.timeout, recv) .await - .map_err(|e| CommandError::Actor(Into::<ActorError>::into(e)))?; + .map_err(|e| CommandError::Actor(Into::<ActorError>::into(e)))? + .map_err(|e| CommandError::Actor(Into::<ActorError>::into(e)))??; + Ok(result) + } + + pub async fn disco_items( + &self, + jid: Option<JID>, + node: Option<String>, + ) -> Result<Items, CommandError<DiscoError>> { + let (send, recv) = oneshot::channel(); + self.send(CoreClientCommand::Command(Command::DiscoItems( + jid, node, send, + ))) + .await + .map_err(|e| CommandError::Actor(Into::<ActorError>::into(e)))?; let result = timeout(self.timeout, recv) .await .map_err(|e| CommandError::Actor(Into::<ActorError>::into(e)))? |