Run cargo-fmt on whole codebase

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2022-12-27 16:03:25 +01:00 committed by Scott Boggs
parent d61c2e5c91
commit c689b8390c
9 changed files with 16 additions and 22 deletions

View File

@ -68,7 +68,7 @@ pub fn bool_input(message: impl AsRef<str>, default: bool) -> Result<bool> {
or 'n', case insensitive: " or 'n', case insensitive: "
); );
bool_input(message, default) bool_input(message, default)
}, }
} }
} else { } else {
Ok(default) Ok(default)

View File

@ -4,8 +4,7 @@ use crate::status_builder;
use chrono::prelude::*; use chrono::prelude::*;
use serde::{ use serde::{
de::{self, Deserializer, Unexpected}, de::{self, Deserializer, Unexpected},
Deserialize, Deserialize, Serialize,
Serialize,
}; };
use std::path::PathBuf; use std::path::PathBuf;
@ -104,7 +103,7 @@ fn string_or_bool<'de, D: Deserializer<'de>>(val: D) -> ::std::result::Result<bo
&"true or false", &"true or false",
)); ));
} }
}, }
}) })
} }

View File

@ -59,11 +59,11 @@ impl<'a, T: Clone + for<'de> Deserialize<'de> + Serialize> ItemsIter<T> {
self.buffer = items; self.buffer = items;
self.cur_idx = 0; self.cur_idx = 0;
Some(()) Some(())
}, }
Err(err) => { Err(err) => {
warn!(err = as_debug!(err); "error encountered filling next page"); warn!(err = as_debug!(err); "error encountered filling next page");
None None
}, }
_ => None, _ => None,
} }
} }

View File

@ -73,18 +73,18 @@ fn make_event(lines: &[String]) -> Result<Event> {
.ok_or_else(|| Error::Other("Missing `data` line for notification".to_string()))?; .ok_or_else(|| Error::Other("Missing `data` line for notification".to_string()))?;
let notification = serde_json::from_str::<Notification>(&data)?; let notification = serde_json::from_str::<Notification>(&data)?;
Event::Notification(notification) Event::Notification(notification)
}, }
"update" => { "update" => {
let data = let data =
data.ok_or_else(|| Error::Other("Missing `data` line for update".to_string()))?; data.ok_or_else(|| Error::Other("Missing `data` line for update".to_string()))?;
let status = serde_json::from_str::<Status>(&data)?; let status = serde_json::from_str::<Status>(&data)?;
Event::Update(status) Event::Update(status)
}, }
"delete" => { "delete" => {
let data = let data =
data.ok_or_else(|| Error::Other("Missing `data` line for delete".to_string()))?; data.ok_or_else(|| Error::Other("Missing `data` line for delete".to_string()))?;
Event::Delete(data) Event::Delete(data)
}, }
"filters_changed" => Event::FiltersChanged, "filters_changed" => Event::FiltersChanged,
_ => return Err(Error::Other(format!("Unknown event `{}`", event))), _ => return Err(Error::Other(format!("Unknown event `{}`", event))),
}) })

View File

@ -66,9 +66,6 @@ where
// we've received an error message, let's deserialize that instead. // we've received an error message, let's deserialize that instead.
let response = serde_json::from_slice(bytes)?; let response = serde_json::from_slice(bytes)?;
debug!(status = as_debug!(status), response = as_serde!(response); "error received from API"); debug!(status = as_debug!(status), response = as_serde!(response); "error received from API");
Err(Error::Api { Err(Error::Api { status, response })
status,
response,
})
} }
} }

View File

@ -348,11 +348,11 @@ impl Mastodon {
file.read_to_end(&mut data)?; file.read_to_end(&mut data)?;
// TODO extract filename, error on dirs, etc. // TODO extract filename, error on dirs, etc.
Ok(Part::bytes(data).file_name(Cow::Owned(path.to_string_lossy().to_string()))) Ok(Part::bytes(data).file_name(Cow::Owned(path.to_string_lossy().to_string())))
}, }
Err(err) => { Err(err) => {
error!(path = as_debug!(path), error = as_debug!(err); "error reading file contents for multipart form"); error!(path = as_debug!(path), error = as_debug!(err); "error reading file contents for multipart form");
Err(err.into()) Err(err.into())
}, }
} }
} }
} }

View File

@ -197,7 +197,7 @@ impl<'a> Registration<'a> {
"received API response" "received API response"
); );
Ok(response) Ok(response)
}, }
Err(err) => { Err(err) => {
error!( error!(
err = as_debug!(err), url = url, method = stringify!($method), err = as_debug!(err), url = url, method = stringify!($method),
@ -205,7 +205,7 @@ impl<'a> Registration<'a> {
"error making API request" "error making API request"
); );
Err(err.into()) Err(err.into())
}, }
} }
} }
} }

View File

@ -574,9 +574,7 @@ mod tests {
form, form,
update_data::Form { update_data::Form {
id: "some-id".to_string(), id: "some-id".to_string(),
data: update_data::Data { data: update_data::Data { alerts: None },
alerts: None,
},
} }
); );
} }

View File

@ -285,11 +285,11 @@ impl FromStr for Scope {
read if read.starts_with("read:") => { read if read.starts_with("read:") => {
let r: Read = Read::from_str(&read[5..])?; let r: Read = Read::from_str(&read[5..])?;
Scope::Read(Some(r)) Scope::Read(Some(r))
}, }
write if write.starts_with("write:") => { write if write.starts_with("write:") => {
let w: Write = Write::from_str(&write[6..])?; let w: Write = Write::from_str(&write[6..])?;
Scope::Write(Some(w)) Scope::Write(Some(w))
}, }
_ => return Err(Error::Other("Unknown scope".to_string())), _ => return Err(Error::Other("Unknown scope".to_string())),
}) })
} }