Clippy suggestions

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
ゆめ 2024-10-16 21:01:54 -05:00
parent 92abe7b368
commit 66fd940c15
No known key found for this signature in database
5 changed files with 13 additions and 17 deletions

View file

@ -1,11 +1,10 @@
use axum::response::IntoResponse;
use flate2::write::GzEncoder;
use flate2::{Compression, GzBuilder};
use flate2::Compression;
use reqwest::Url;
use serde::Serialize;
use std::collections::HashSet;
use std::fs::{File, OpenOptions};
use std::io::{BufReader, BufWriter};
use std::sync::atomic::AtomicU32;
use std::{collections::HashMap, fmt::Debug, ops::DerefMut, path::PathBuf, sync::Arc};
use tokio::sync::{Mutex, RwLock};
@ -118,9 +117,9 @@ impl AuditState {
let file = OpenOptions::new()
.create(true)
.write(true)
.append(true)
.open(&self.options.output.join(&full_name))?;
.open(self.options.output.join(&full_name))?;
let gz = GzEncoder::new(file, Compression::default());

View file

@ -75,6 +75,7 @@ impl<
ctx: Option<serde_json::Value>,
info: &APRequestInfo<'r>,
) -> (Disposition<E>, Option<serde_json::Value>) {
#[allow(clippy::unwrap_used)]
let ctx = ctx.map(|mut c| {
c["meta"] = serde_json::to_value(extract_meta(info)).unwrap();
c

View file

@ -7,7 +7,7 @@ pub mod chain;
#[macro_export]
macro_rules! delegate {
(state $str:ident::<E, I $(,$t:ty),*>.$field:ident) => {
use crate::{BaseAppState, ClientCache};
use $crate::{BaseAppState, ClientCache};
impl<E: IntoResponse + Clone + 'static, I: HasAppState<E>> HasAppState<E> for $str::<E, I, $($t),*> {
fn app_state(&self) -> &BaseAppState<E> {
self.inner.app_state()
@ -75,9 +75,9 @@ pub trait Evaluator<E: IntoResponse> {
) -> (Disposition<E>, Option<serde_json::Value>);
}
impl<E: IntoResponse> Into<Disposition<E>> for Result<(), E> {
fn into(self) -> Disposition<E> {
match self {
impl<E: IntoResponse> From<Result<(), E>> for Disposition<E> {
fn from(val: Result<(), E>) -> Self {
match val {
Ok(()) => Disposition::Next,
Err(e) => Disposition::Intercept(e),
}

View file

@ -27,7 +27,6 @@ use model::ap::AnyObject;
use model::{ap, error::MisskeyError};
use network::stream::LimitedStream;
use network::{new_backend_client, Either};
use reqwest;
use serde::ser::{SerializeMap, SerializeStruct};
use serde::Serialize;
@ -126,7 +125,7 @@ pub struct BaseAppState<E: IntoResponse + 'static> {
impl<E: IntoResponse> HasAppState<E> for Arc<BaseAppState<E>> {
fn app_state(&self) -> &BaseAppState<E> {
&self
self
}
fn client_pool_ref(&self) -> &ClientCache {
@ -307,10 +306,7 @@ impl<
};
let ctx = app.app_state().ctx_template.clone();
match app.evaluate(ctx, &info).await.0 {
Disposition::Intercept(e) => return Err(Either::B(e)),
_ => {}
}
if let Disposition::Intercept(e) = app.evaluate(ctx, &info).await.0 { return Err(Either::B(e)) }
header.remove("host");
@ -353,7 +349,7 @@ impl<
.ok_or(Either::A(ERR_INTERNAL_SERVER_ERROR))?
.extend(resp.headers().clone());
Ok(resp_builder
resp_builder
.header("X-Forwarded-For", addr.to_string())
.body(Body::from_stream(resp.bytes_stream().inspect_err(|e| {
log::error!("Failed to read response: {}", e);
@ -361,6 +357,6 @@ impl<
.map_err(|e| {
log::error!("Failed to build response: {}", e);
Either::A(ERR_SERVICE_TEMPORARILY_UNAVAILABLE)
})?)
})
}
}

View file

@ -59,5 +59,5 @@ async fn main() {
)
.await,
)
.await;
.await
}