mirror of
https://github.com/kristoferssolo/transmission-rpc.git
synced 2025-12-30 13:21:49 +00:00
feat: new_with_client
This commit is contained in:
parent
0528429754
commit
598171837c
14
src/lib.rs
14
src/lib.rs
@ -64,6 +64,20 @@ impl TransClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
pub fn new_with_client(url: Url, client: Client) -> TransClient {
|
||||||
|
TransClient {
|
||||||
|
url,
|
||||||
|
auth: None,
|
||||||
|
session_id: None,
|
||||||
|
client,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_auth(&mut self, basic_auth: BasicAuth) {
|
||||||
|
self.auth = Some(basic_auth);
|
||||||
|
}
|
||||||
|
|
||||||
/// Prepares a request for provided server and auth
|
/// Prepares a request for provided server and auth
|
||||||
fn rpc_request(&self) -> reqwest::RequestBuilder {
|
fn rpc_request(&self) -> reqwest::RequestBuilder {
|
||||||
if let Some(auth) = &self.auth {
|
if let Some(auth) = &self.auth {
|
||||||
|
|||||||
14
src/sync.rs
14
src/sync.rs
@ -43,6 +43,20 @@ impl SharableTransClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
pub fn new_with_client(url: Url, client: Client) -> SharableTransClient {
|
||||||
|
SharableTransClient {
|
||||||
|
url,
|
||||||
|
auth: None,
|
||||||
|
session_id: RwLock::new(None),
|
||||||
|
client,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_auth(&mut self, basic_auth: BasicAuth) {
|
||||||
|
self.auth = Some(basic_auth);
|
||||||
|
}
|
||||||
|
|
||||||
/// Prepares a request for provided server and auth
|
/// Prepares a request for provided server and auth
|
||||||
fn rpc_request(&self) -> reqwest::RequestBuilder {
|
fn rpc_request(&self) -> reqwest::RequestBuilder {
|
||||||
if let Some(auth) = &self.auth {
|
if let Some(auth) = &self.auth {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user