refactor: rustfmt

This commit is contained in:
Greg Heartsfield 2025-02-23 11:23:22 -06:00
parent b4234eae25
commit d72af96d5f
4 changed files with 33 additions and 20 deletions

View File

@ -472,12 +472,8 @@ mod tests {
let mut event = Event::simple_event();
event.tags = vec![vec!["e".to_owned(), "foo".to_owned()]];
event.build_index();
assert!(
event.generic_tag_val_intersect(
'e',
&HashSet::from(["foo".to_owned(), "bar".to_owned()])
)
);
assert!(event
.generic_tag_val_intersect('e', &HashSet::from(["foo".to_owned(), "bar".to_owned()])));
}
#[test]

View File

@ -25,7 +25,9 @@ impl EventResultStatus {
pub fn to_bool(&self) -> bool {
match self {
Self::Duplicate | Self::Saved => true,
Self::Invalid | Self::Blocked | Self::RateLimited | Self::Error | Self::Restricted => false,
Self::Invalid | Self::Blocked | Self::RateLimited | Self::Error | Self::Restricted => {
false
}
}
}

View File

@ -202,7 +202,7 @@ async fn handle_web_request(
.header("Content-Type", "text/html; charset=UTF-8")
.body(Body::from(file_content))
.expect("request builder"));
},
}
Err(err) => {
error!("Failed to read relay_page file: {}. Will use default", err);
}
@ -920,7 +920,7 @@ pub fn start_server(settings: &Settings, shutdown_rx: MpscReceiver<()>) -> Resul
info!("starting payment process ...");
p.run().await;
});
},
}
Err(e) => {
error!("Failed to start payment process {e}");
std::process::exit(1);

View File

@ -45,8 +45,8 @@ pub struct ReqFilter {
impl Serialize for ReqFilter {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
where
S: Serializer,
{
let mut map = serializer.serialize_map(None)?;
if let Some(ids) = &self.ids {
@ -80,8 +80,8 @@ impl Serialize for ReqFilter {
impl<'de> Deserialize<'de> for ReqFilter {
fn deserialize<D>(deserializer: D) -> Result<ReqFilter, D::Error>
where
D: Deserializer<'de>,
where
D: Deserializer<'de>,
{
let received: Value = Deserialize::deserialize(deserializer)?;
let filter = received.as_object().ok_or_else(|| {
@ -184,8 +184,8 @@ impl<'de> Deserialize<'de> for Subscription {
/// Custom deserializer for subscriptions, which have a more
/// complex structure than the other message types.
fn deserialize<D>(deserializer: D) -> Result<Subscription, D::Error>
where
D: Deserializer<'de>,
where
D: Deserializer<'de>,
{
let mut v: Value = Deserialize::deserialize(deserializer)?;
// this should be a 3-or-more element array.
@ -673,11 +673,26 @@ mod tests {
#[test]
fn is_scraper() -> Result<()> {
assert!(serde_json::from_str::<Subscription>(r#"["REQ","some-id",{"kinds": [1984],"since": 123,"limit":1}]"#)?.is_scraper());
assert!(serde_json::from_str::<Subscription>(r#"["REQ","some-id",{"kinds": [1984]},{"kinds": [1984],"authors":["aaaa"]}]"#)?.is_scraper());
assert!(!serde_json::from_str::<Subscription>(r#"["REQ","some-id",{"kinds": [1984],"authors":["aaaa"]}]"#)?.is_scraper());
assert!(!serde_json::from_str::<Subscription>(r#"["REQ","some-id",{"ids": ["aaaa"]}]"#)?.is_scraper());
assert!(!serde_json::from_str::<Subscription>(r##"["REQ","some-id",{"#p": ["aaaa"],"kinds":[1,4]}]"##)?.is_scraper());
assert!(serde_json::from_str::<Subscription>(
r#"["REQ","some-id",{"kinds": [1984],"since": 123,"limit":1}]"#
)?
.is_scraper());
assert!(serde_json::from_str::<Subscription>(
r#"["REQ","some-id",{"kinds": [1984]},{"kinds": [1984],"authors":["aaaa"]}]"#
)?
.is_scraper());
assert!(!serde_json::from_str::<Subscription>(
r#"["REQ","some-id",{"kinds": [1984],"authors":["aaaa"]}]"#
)?
.is_scraper());
assert!(
!serde_json::from_str::<Subscription>(r#"["REQ","some-id",{"ids": ["aaaa"]}]"#)?
.is_scraper()
);
assert!(!serde_json::from_str::<Subscription>(
r##"["REQ","some-id",{"#p": ["aaaa"],"kinds":[1,4]}]"##
)?
.is_scraper());
Ok(())
}
}