style: use tabs over spaces

This commit is contained in:
seth 2024-01-08 14:56:37 -05:00
parent f2979d4cde
commit f0550dd429
No known key found for this signature in database
GPG key ID: D31BD0D494BBEE86
41 changed files with 1112 additions and 1109 deletions

View file

@ -7,40 +7,40 @@ use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct RoryResponse {
pub id: u64,
pub url: String,
pub error: Option<String>,
pub id: u64,
pub url: String,
pub error: Option<String>,
}
const RORY: &str = "https://rory.cat";
const ENDPOINT: &str = "/purr";
pub async fn get_rory(id: Option<u64>) -> Result<RoryResponse> {
let target = id.map(|id| id.to_string()).unwrap_or_default();
let target = id.map(|id| id.to_string()).unwrap_or_default();
let req = REQWEST_CLIENT
.get(format!("{RORY}{ENDPOINT}/{target}"))
.build()
.wrap_err_with(|| "Couldn't build reqwest client!")?;
let req = REQWEST_CLIENT
.get(format!("{RORY}{ENDPOINT}/{target}"))
.build()
.wrap_err_with(|| "Couldn't build reqwest client!")?;
debug!("Making request to {}", req.url());
let resp = REQWEST_CLIENT
.execute(req)
.await
.wrap_err_with(|| "Couldn't make request for rory!")?;
debug!("Making request to {}", req.url());
let resp = REQWEST_CLIENT
.execute(req)
.await
.wrap_err_with(|| "Couldn't make request for rory!")?;
let status = resp.status();
let status = resp.status();
if let StatusCode::OK = status {
let data = resp
.json::<RoryResponse>()
.await
.wrap_err_with(|| "Couldn't parse the rory response!")?;
if let StatusCode::OK = status {
let data = resp
.json::<RoryResponse>()
.await
.wrap_err_with(|| "Couldn't parse the rory response!")?;
Ok(data)
} else {
Err(eyre!(
"Failed to get rory from {RORY}{ENDPOINT}/{target} with {status}",
))
}
Ok(data)
} else {
Err(eyre!(
"Failed to get rory from {RORY}{ENDPOINT}/{target} with {status}",
))
}
}