diff options
Diffstat (limited to 'crates/turtle/src/atuin_client/api_client.rs')
| -rw-r--r-- | crates/turtle/src/atuin_client/api_client.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/turtle/src/atuin_client/api_client.rs b/crates/turtle/src/atuin_client/api_client.rs index 15d96d93..bd5bf59e 100644 --- a/crates/turtle/src/atuin_client/api_client.rs +++ b/crates/turtle/src/atuin_client/api_client.rs @@ -19,8 +19,8 @@ static APP_USER_AGENT: &str = concat!("atuin/", env!("CARGO_PKG_VERSION"),); pub(crate) struct Client<'a> { sync_addr: &'a str, - client: reqwest::Client, user_id: Uuid, + inner: reqwest::Client, } fn make_url(address: &str, path: &str, user_id: Uuid) -> Result<String> { @@ -28,7 +28,7 @@ fn make_url(address: &str, path: &str, user_id: Uuid) -> Result<String> { // `join()` expects a trailing `/` in order to join paths // e.g. it treats `http://host:port/subdir` as a file called `subdir` - let address = &format!("{address}/api/v0/{}/", user_id.to_string()); + let address = &format!("{address}/api/v0/{user_id}/"); // passing a path with a leading `/` will cause `join()` to replace the entire URL path let path = path.strip_prefix("/").unwrap_or(path); @@ -81,7 +81,7 @@ async fn handle_resp_error(resp: Response) -> Result<Response> { } if !status.is_success() { - if let Ok(error) = resp.json::<ErrorResponse>().await { + if let Ok(error) = resp.json::<ErrorResponse<'_>>().await { let reason = error.reason; if status.is_client_error() { @@ -117,7 +117,7 @@ impl<'a> Client<'a> { Ok(Client { user_id, sync_addr, - client: reqwest::Client::builder() + inner: reqwest::Client::builder() .user_agent(APP_USER_AGENT) .default_headers(headers) .connect_timeout(Duration::new(connect_timeout, 0)) @@ -130,7 +130,7 @@ impl<'a> Client<'a> { let url = make_url(self.sync_addr, "/store", self.user_id)?; let url = Url::parse(url.as_str())?; - let resp = self.client.delete(url).send().await?; + let resp = self.inner.delete(url).send().await?; handle_resp_error(resp).await?; @@ -143,7 +143,7 @@ impl<'a> Client<'a> { debug!("uploading {} records to {url}", records.len()); - let resp = self.client.post(url).json(records).send().await?; + let resp = self.inner.post(url).json(records).send().await?; handle_resp_error(resp).await?; Ok(()) @@ -169,7 +169,7 @@ impl<'a> Client<'a> { let url = Url::parse(url.as_str())?; - let resp = self.client.get(url).send().await?; + let resp = self.inner.get(url).send().await?; let resp = handle_resp_error(resp).await?; let records = resp.json::<Vec<Record<EncryptedData>>>().await?; @@ -181,7 +181,7 @@ impl<'a> Client<'a> { let url = make_url(self.sync_addr, "/record", self.user_id)?; let url = Url::parse(url.as_str())?; - let resp = self.client.get(url).send().await?; + let resp = self.inner.get(url).send().await?; let resp = handle_resp_error(resp).await?; if !ensure_version(&resp)? { |
