nightly clippy lints
This commit is contained in:
parent
5f4be9809a
commit
7546948196
7 changed files with 14 additions and 13 deletions
6
src/cache/compat.rs
vendored
6
src/cache/compat.rs
vendored
|
@ -9,14 +9,14 @@ use serde::{
|
||||||
use super::ImageContentType;
|
use super::ImageContentType;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Serialize, Deserialize)]
|
#[derive(Copy, Clone, Serialize, Deserialize)]
|
||||||
pub(crate) struct LegacyImageMetadata {
|
pub struct LegacyImageMetadata {
|
||||||
pub(crate) content_type: Option<LegacyImageContentType>,
|
pub(crate) content_type: Option<LegacyImageContentType>,
|
||||||
pub(crate) size: Option<u32>,
|
pub(crate) size: Option<u32>,
|
||||||
pub(crate) last_modified: Option<LegacyDateTime>,
|
pub(crate) last_modified: Option<LegacyDateTime>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Serialize)]
|
#[derive(Copy, Clone, Serialize)]
|
||||||
pub(crate) struct LegacyDateTime(pub DateTime<FixedOffset>);
|
pub struct LegacyDateTime(pub DateTime<FixedOffset>);
|
||||||
|
|
||||||
impl<'de> Deserialize<'de> for LegacyDateTime {
|
impl<'de> Deserialize<'de> for LegacyDateTime {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
|
@ -47,7 +47,7 @@ impl<'de> Deserialize<'de> for LegacyDateTime {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub(crate) struct LegacyImageContentType(pub ImageContentType);
|
pub struct LegacyImageContentType(pub ImageContentType);
|
||||||
|
|
||||||
impl Serialize for LegacyImageContentType {
|
impl Serialize for LegacyImageContentType {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
|
6
src/cache/fs.rs
vendored
6
src/cache/fs.rs
vendored
|
@ -245,7 +245,7 @@ where
|
||||||
error = writer.write_all(metadata_string.as_bytes()).await.err();
|
error = writer.write_all(metadata_string.as_bytes()).await.err();
|
||||||
}
|
}
|
||||||
if error.is_none() {
|
if error.is_none() {
|
||||||
error = error.or(writer.write_all(&bytes).await.err());
|
error = writer.write_all(&bytes).await.err();
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(e) = error {
|
if let Some(e) = error {
|
||||||
|
@ -408,7 +408,7 @@ mod read_file {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
metadata,
|
metadata,
|
||||||
ImageMetadata {
|
ImageMetadata {
|
||||||
content_length: Some(708370),
|
content_length: Some(708_370),
|
||||||
content_type: Some(ImageContentType::Png),
|
content_type: Some(ImageContentType::Png),
|
||||||
last_modified: Some(
|
last_modified: Some(
|
||||||
DateTime::parse_from_rfc3339("2021-04-13T04:37:41+00:00").unwrap()
|
DateTime::parse_from_rfc3339("2021-04-13T04:37:41+00:00").unwrap()
|
||||||
|
@ -447,7 +447,7 @@ mod read_file_compat {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
metadata,
|
metadata,
|
||||||
ImageMetadata {
|
ImageMetadata {
|
||||||
content_length: Some(117888),
|
content_length: Some(117_888),
|
||||||
content_type: Some(ImageContentType::Jpeg),
|
content_type: Some(ImageContentType::Jpeg),
|
||||||
last_modified: Some(
|
last_modified: Some(
|
||||||
DateTime::parse_from_rfc2822("Sat, 10 Apr 2021 10:55:22 GMT").unwrap()
|
DateTime::parse_from_rfc2822("Sat, 10 Apr 2021 10:55:22 GMT").unwrap()
|
||||||
|
|
2
src/cache/mod.rs
vendored
2
src/cache/mod.rs
vendored
|
@ -115,7 +115,7 @@ impl From<LegacyImageMetadata> for ImageMetadata {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::pub_enum_variant_names)]
|
#[allow(clippy::enum_variant_names)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ImageRequestError {
|
pub enum ImageRequestError {
|
||||||
InvalidContentType,
|
InvalidContentType,
|
||||||
|
|
|
@ -339,6 +339,6 @@ mod sample_yaml {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn sample_yaml_parses() {
|
fn sample_yaml_parses() {
|
||||||
assert!(serde_yaml::from_str::<YamlArgs>(include_str!("../settings.sample.yaml")).is_ok())
|
assert!(serde_yaml::from_str::<YamlArgs>(include_str!("../settings.sample.yaml")).is_ok());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||||
send_stop(&client_secret).await;
|
send_stop(&client_secret).await;
|
||||||
} else {
|
} else {
|
||||||
warn!("Got second Ctrl-C, forcefully exiting");
|
warn!("Got second Ctrl-C, forcefully exiting");
|
||||||
system.stop()
|
system.stop();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,10 +129,10 @@ impl<'de> Deserialize<'de> for Tls {
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|mut v| {
|
.and_then(|mut v| {
|
||||||
v.pop().and_then(|key| RSASigningKey::new(&key).ok())
|
v.pop().and_then(|key| RSASigningKey::new(&key).ok())
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
"certificate" => {
|
"certificate" => {
|
||||||
certificates = certs(&mut BufReader::new(value.as_bytes())).ok()
|
certificates = certs(&mut BufReader::new(value.as_bytes())).ok();
|
||||||
}
|
}
|
||||||
_ => (), // Ignore extra fields
|
_ => (), // Ignore extra fields
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ pub async fn update_server_state(
|
||||||
},
|
},
|
||||||
Err(e) => match e {
|
Err(e) => match e {
|
||||||
e if e.is_timeout() => {
|
e if e.is_timeout() => {
|
||||||
error!("Response timed out to control server. Is MangaDex down?")
|
error!("Response timed out to control server. Is MangaDex down?");
|
||||||
}
|
}
|
||||||
e => warn!("Failed to send request: {}", e),
|
e => warn!("Failed to send request: {}", e),
|
||||||
},
|
},
|
||||||
|
|
|
@ -47,6 +47,7 @@ impl Responder for ServerResponse {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::unused_async)]
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
async fn index() -> impl Responder {
|
async fn index() -> impl Responder {
|
||||||
HttpResponse::Ok().body(include_str!("index.html"))
|
HttpResponse::Ok().body(include_str!("index.html"))
|
||||||
|
@ -122,7 +123,7 @@ pub async fn default(state: Data<RwLockServerState>, req: HttpRequest) -> impl R
|
||||||
ServerResponse::HttpResponse(resp_builder.body(resp.bytes().await.unwrap_or_default()))
|
ServerResponse::HttpResponse(resp_builder.body(resp.bytes().await.unwrap_or_default()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::future_not_send)]
|
#[allow(clippy::future_not_send, clippy::unused_async)]
|
||||||
#[get("/metrics")]
|
#[get("/metrics")]
|
||||||
pub async fn metrics() -> impl Responder {
|
pub async fn metrics() -> impl Responder {
|
||||||
let metric_families = prometheus::gather();
|
let metric_families = prometheus::gather();
|
||||||
|
|
Loading…
Reference in a new issue