diff --git a/src/client.rs b/src/client.rs index 13ca51d..9af48a5 100644 --- a/src/client.rs +++ b/src/client.rs @@ -221,6 +221,8 @@ impl Client { /// Constructs a new ARSnova client /// /// This method fails whenever the supplied Url cannot be parsed. + /// + /// If successful the result will be of type `Client` pub fn new(api_url: U) -> Result { let client = reqwest::Client::builder() .user_agent(format!("arsnova-cli-client/{}", env!("CARGO_PKG_VERSION"))) @@ -237,6 +239,12 @@ impl Client { } impl Client { + /// Tries to login and request a new token if client is not logged in yet + /// + /// This method fails if a connection error occurs or the response cannot + /// be handled. + /// + /// If successful the result will be of type `Client` pub async fn guest_login(self) -> Result, ClientError> { match self .http_client @@ -259,6 +267,9 @@ impl Client { } impl Client { + /// Logout the client and discard existing token if not logged in + /// + /// If successful the result will be of type `Client` pub fn logout(self) -> Client { Client { api_url: self.api_url, @@ -268,6 +279,10 @@ impl Client { } } + /// Requests `RoomInfo` for given 8-digit room ID + /// + /// This method fails on connection or response errors and if + /// no room is available with given room ID. pub async fn get_room_info(&self, short_id: &str) -> Result { let token = self.token.as_ref().unwrap(); @@ -305,6 +320,10 @@ impl Client { }) } + /// Requests `Feedback` for given 8-digit room ID + /// + /// This method fails on connection or response errors and if + /// no room is available with given room ID. pub async fn get_feedback(&self, short_id: &str) -> Result { let room_info = self.get_room_info(short_id).await?; @@ -328,6 +347,12 @@ impl Client { } } + /// Registers a handler to get notifications on feedback change. + /// + /// This is done by using websocket connections to ARSnova. + /// + /// This method fails on connection or response errors and if + /// no room is available with given room ID. pub async fn on_feedback_changed( &self, short_id: &str,