From dd31b877a2335174bd98e71d23670dda32c9e98b Mon Sep 17 00:00:00 2001 From: Astro Date: Sun, 25 Dec 2022 04:02:37 +0100 Subject: [PATCH] delint --- src/main.rs | 23 ++++++++++------------- src/stream.rs | 10 +++++----- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/main.rs b/src/main.rs index 306a3aa..b0cb492 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,19 +9,16 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; mod stream; fn mangle_account(post: &mut serde_json::Value) { - match post { - serde_json::Value::Object(ref mut obj) => { - if let Entry::Occupied(mut account) = obj.entry("account") { - let id = account.get_mut().get_mut("acct").map(|id| id.take()); - match id { - Some(id) => - account.insert(id), - None => - account.remove(), - }; - } + if let serde_json::Value::Object(ref mut obj) = post { + if let Entry::Occupied(mut account) = obj.entry("account") { + let id = account.get_mut().get_mut("acct").map(serde_json::Value::take); + match id { + Some(id) => + account.insert(id), + None => + account.remove(), + }; } - _ => {} } } @@ -43,7 +40,7 @@ async fn main() { let default_debug = "buzz2elastic=info".into(); tracing_subscriber::registry() .with( - tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| default_debug), + tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or(default_debug), ) .with(tracing_subscriber::fmt::layer()) .init(); diff --git a/src/stream.rs b/src/stream.rs index c34e780..fd95013 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -7,27 +7,27 @@ use tokio::{ }; #[derive(Debug)] -pub enum StreamError { +pub enum Error { Http(reqwest::Error), HttpStatus(reqwest::StatusCode), InvalidContentType, } -async fn run(host: &str) -> Result, StreamError> { +async fn run(host: &str) -> Result, Error> { let url = format!("https://{}/api/v1/streaming/public", host); let client = reqwest::Client::new(); let res = client.get(url) .timeout(Duration::MAX) .send() .await - .map_err(StreamError::Http)?; + .map_err(Error::Http)?; if res.status() != 200 { - return Err(StreamError::HttpStatus(res.status())); + return Err(Error::HttpStatus(res.status())); } let ct = res.headers().get("content-type") .and_then(|c| c.to_str().ok()); if ct.map_or(true, |ct| ct != "text/event-stream") { - return Err(StreamError::InvalidContentType); + return Err(Error::InvalidContentType); } let src = res.bytes_stream()