From 0364392d29146542dfb96d06ad17e402cafb7f56 Mon Sep 17 00:00:00 2001 From: Dave Townsend Date: Wed, 25 Jan 2023 11:43:03 +0000 Subject: [PATCH] docs: Add some API documentation. --- crates/plex-api/src/http_client.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/plex-api/src/http_client.rs b/crates/plex-api/src/http_client.rs index 6ed83f7f..cc5a48ff 100644 --- a/crates/plex-api/src/http_client.rs +++ b/crates/plex-api/src/http_client.rs @@ -95,10 +95,12 @@ impl HttpClient { request } + /// Verifies that this client has an authentication token. pub fn is_authenticated(&self) -> bool { !self.x_plex_token.is_empty() } + /// Begins building a request using the HTTP POST method. pub fn post(&self, path: T) -> RequestBuilder<'_, T> where PathAndQuery: TryFrom, @@ -127,6 +129,7 @@ impl HttpClient { } } + /// Begins building a request using the HTTP GET method. pub fn get(&self, path: T) -> RequestBuilder<'_, T> where PathAndQuery: TryFrom, @@ -155,6 +158,7 @@ impl HttpClient { } } + /// Begins building a request using the HTTP PUT method. pub fn put(&self, path: T) -> RequestBuilder<'_, T> where PathAndQuery: TryFrom, @@ -183,6 +187,7 @@ impl HttpClient { } } + /// Begins building a request using the HTTP DELETE method. pub fn delete(&self, path: T) -> RequestBuilder<'_, T> where PathAndQuery: TryFrom, @@ -241,6 +246,7 @@ where PathAndQuery: TryFrom

, >::Error: Into, { + /// Adds a body to the request. pub fn body(self, body: B) -> Result> where B: Into + std::fmt::Debug, @@ -256,6 +262,7 @@ where }) } + /// Adds a form encoded parameters to the request body. pub fn form(self, params: &[(&str, &str)]) -> Result> { let body = serde_urlencoded::to_string(params)?; self.header("Content-type", "application/x-www-form-urlencoded") @@ -263,6 +270,7 @@ where .body(body) } + /// Adds a request header. pub fn header(self, key: K, value: V) -> RequestBuilder<'a, P> where http::header::HeaderName: TryFrom, @@ -278,6 +286,7 @@ where } } + /// Sends this request generating a response. pub async fn send(self) -> Result> { self.body(())?.send().await }