Fix clippy linting warnings

This commit is contained in:
Tobie Morgan Hitchcock 2022-12-31 08:15:54 +00:00
parent b3d9ce2c68
commit 8355ce7f89

View file

@ -187,9 +187,9 @@ async fn query(request: RequestBuilder) -> Result<QueryResponse> {
Status::Ok => { Status::Ok => {
if let Some(value) = response.result { if let Some(value) = response.result {
match from_json(value) { match from_json(value) {
Value::Array(Array(array)) => map.insert(index, Ok(array).into()), Value::Array(Array(array)) => map.insert(index, Ok(array)),
Value::None | Value::Null => map.insert(index, Ok(vec![]).into()), Value::None | Value::Null => map.insert(index, Ok(vec![])),
value => map.insert(index, Ok(vec![value]).into()), value => map.insert(index, Ok(vec![value])),
}; };
} }
} }
@ -340,7 +340,7 @@ async fn router(
.headers(headers.clone()) .headers(headers.clone())
.header("NS", &ns) .header("NS", &ns)
.header("DB", &db) .header("DB", &db)
.auth(&auth) .auth(auth)
.body("RETURN true"); .body("RETURN true");
take(true, request).await?; take(true, request).await?;
headers.insert("NS", ns); headers.insert("NS", ns);
@ -362,7 +362,7 @@ async fn router(
}, },
_ => unreachable!(), _ => unreachable!(),
}; };
let request = client.post(path).headers(headers.clone()).auth(&auth).body(credentials); let request = client.post(path).headers(headers.clone()).auth(auth).body(credentials);
let value = submit_auth(request).await?; let value = submit_auth(request).await?;
if let [credentials] = &mut params[..] { if let [credentials] = &mut params[..] {
if let Ok(Root { if let Ok(Root {
@ -397,7 +397,7 @@ async fn router(
}, },
_ => unreachable!(), _ => unreachable!(),
}; };
let request = client.post(path).headers(headers.clone()).auth(&auth).body(credentials); let request = client.post(path).headers(headers.clone()).auth(auth).body(credentials);
let value = submit_auth(request).await?; let value = submit_auth(request).await?;
Ok(DbResponse::Other(value)) Ok(DbResponse::Other(value))
} }
@ -423,7 +423,7 @@ async fn router(
let path = base_url.join(SQL_PATH)?; let path = base_url.join(SQL_PATH)?;
let statement = create_statement(&mut params); let statement = create_statement(&mut params);
let request = let request =
client.post(path).headers(headers.clone()).auth(&auth).body(statement.to_string()); client.post(path).headers(headers.clone()).auth(auth).body(statement.to_string());
let value = take(true, request).await?; let value = take(true, request).await?;
Ok(DbResponse::Other(value)) Ok(DbResponse::Other(value))
} }
@ -431,7 +431,7 @@ async fn router(
let path = base_url.join(SQL_PATH)?; let path = base_url.join(SQL_PATH)?;
let (one, statement) = update_statement(&mut params); let (one, statement) = update_statement(&mut params);
let request = let request =
client.post(path).headers(headers.clone()).auth(&auth).body(statement.to_string()); client.post(path).headers(headers.clone()).auth(auth).body(statement.to_string());
let value = take(one, request).await?; let value = take(one, request).await?;
Ok(DbResponse::Other(value)) Ok(DbResponse::Other(value))
} }
@ -439,7 +439,7 @@ async fn router(
let path = base_url.join(SQL_PATH)?; let path = base_url.join(SQL_PATH)?;
let (one, statement) = patch_statement(&mut params); let (one, statement) = patch_statement(&mut params);
let request = let request =
client.post(path).headers(headers.clone()).auth(&auth).body(statement.to_string()); client.post(path).headers(headers.clone()).auth(auth).body(statement.to_string());
let value = take(one, request).await?; let value = take(one, request).await?;
Ok(DbResponse::Other(value)) Ok(DbResponse::Other(value))
} }
@ -447,7 +447,7 @@ async fn router(
let path = base_url.join(SQL_PATH)?; let path = base_url.join(SQL_PATH)?;
let (one, statement) = merge_statement(&mut params); let (one, statement) = merge_statement(&mut params);
let request = let request =
client.post(path).headers(headers.clone()).auth(&auth).body(statement.to_string()); client.post(path).headers(headers.clone()).auth(auth).body(statement.to_string());
let value = take(one, request).await?; let value = take(one, request).await?;
Ok(DbResponse::Other(value)) Ok(DbResponse::Other(value))
} }
@ -455,7 +455,7 @@ async fn router(
let path = base_url.join(SQL_PATH)?; let path = base_url.join(SQL_PATH)?;
let (one, statement) = select_statement(&mut params); let (one, statement) = select_statement(&mut params);
let request = let request =
client.post(path).headers(headers.clone()).auth(&auth).body(statement.to_string()); client.post(path).headers(headers.clone()).auth(auth).body(statement.to_string());
let value = take(one, request).await?; let value = take(one, request).await?;
Ok(DbResponse::Other(value)) Ok(DbResponse::Other(value))
} }
@ -463,13 +463,13 @@ async fn router(
let path = base_url.join(SQL_PATH)?; let path = base_url.join(SQL_PATH)?;
let statement = delete_statement(&mut params); let statement = delete_statement(&mut params);
let request = let request =
client.post(path).headers(headers.clone()).auth(&auth).body(statement.to_string()); client.post(path).headers(headers.clone()).auth(auth).body(statement.to_string());
let value = take(true, request).await?; let value = take(true, request).await?;
Ok(DbResponse::Other(value)) Ok(DbResponse::Other(value))
} }
Method::Query => { Method::Query => {
let path = base_url.join(SQL_PATH)?; let path = base_url.join(SQL_PATH)?;
let mut request = client.post(path).headers(headers.clone()).query(&vars).auth(&auth); let mut request = client.post(path).headers(headers.clone()).query(&vars).auth(auth);
match &mut params[..] { match &mut params[..] {
[Value::Strand(Strand(statements))] => { [Value::Strand(Strand(statements))] => {
request = request.body(mem::take(statements)); request = request.body(mem::take(statements));
@ -493,7 +493,7 @@ async fn router(
let request = client let request = client
.get(path) .get(path)
.headers(headers.clone()) .headers(headers.clone())
.auth(&auth) .auth(auth)
.header(ACCEPT, "application/octet-stream"); .header(ACCEPT, "application/octet-stream");
let value = export(request, file).await?; let value = export(request, file).await?;
Ok(DbResponse::Other(value)) Ok(DbResponse::Other(value))
@ -531,7 +531,7 @@ async fn router(
let request = client let request = client
.post(path) .post(path)
.headers(headers.clone()) .headers(headers.clone())
.auth(&auth) .auth(auth)
.query(&[(key.as_str(), value.as_str())]) .query(&[(key.as_str(), value.as_str())])
.body(format!("RETURN ${key}")); .body(format!("RETURN ${key}"));
take(true, request).await?; take(true, request).await?;
@ -553,7 +553,7 @@ async fn router(
let request = client let request = client
.post(path) .post(path)
.headers(headers.clone()) .headers(headers.clone())
.auth(&auth) .auth(auth)
.query(&[("table", table)]) .query(&[("table", table)])
.body("LIVE SELECT * FROM type::table($table)"); .body("LIVE SELECT * FROM type::table($table)");
let value = take(true, request).await?; let value = take(true, request).await?;
@ -568,7 +568,7 @@ async fn router(
let request = client let request = client
.post(path) .post(path)
.headers(headers.clone()) .headers(headers.clone())
.auth(&auth) .auth(auth)
.query(&[("id", id)]) .query(&[("id", id)])
.body("KILL type::string($id)"); .body("KILL type::string($id)");
let value = take(true, request).await?; let value = take(true, request).await?;