feat: new_with_client

This commit is contained in:
George Miao 2022-10-23 07:57:27 -04:00 committed by Aleksandr
parent 0528429754
commit 598171837c
2 changed files with 28 additions and 0 deletions

View File

@ -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
fn rpc_request(&self) -> reqwest::RequestBuilder {
if let Some(auth) = &self.auth {

View File

@ -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
fn rpc_request(&self) -> reqwest::RequestBuilder {
if let Some(auth) = &self.auth {