Skip to content

Commit 7e7fa53

Browse files
committed
crates: formatting with new 2024 edition rules
`cargo fmt --all` Changelog-None
1 parent fefdd35 commit 7e7fa53

File tree

35 files changed

+204
-160
lines changed

35 files changed

+204
-160
lines changed

cln-rpc/examples/getinfo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use anyhow::{anyhow, Context};
2-
use cln_rpc::{model::requests::GetinfoRequest, ClnRpc, Request};
1+
use anyhow::{Context, anyhow};
2+
use cln_rpc::{ClnRpc, Request, model::requests::GetinfoRequest};
33
use std::env::args;
44
use std::path::Path;
55
use tokio;

cln-rpc/src/jsonrpc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Common structs to handle JSON-RPC decoding and encoding. They are
22
//! generic over the Notification and Request types.
33
4-
use serde::ser::{SerializeStruct, Serializer};
54
use serde::de::{self, Deserializer};
5+
use serde::ser::{SerializeStruct, Serializer};
66
use serde::{Deserialize, Serialize};
77
use serde_json::Value;
88
use std::fmt::Debug;

cln-rpc/src/lib.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ use crate::codec::JsonCodec;
7979
pub use anyhow::Error;
8080
use anyhow::Result;
8181
use core::fmt::Debug;
82-
use futures_util::sink::SinkExt;
8382
use futures_util::StreamExt;
83+
use futures_util::sink::SinkExt;
8484
use log::{debug, trace};
85-
use serde::{de::DeserializeOwned, Serialize};
85+
use serde::{Serialize, de::DeserializeOwned};
8686
use std::path::Path;
8787
use std::sync::atomic::AtomicUsize;
8888
use std::sync::atomic::Ordering;
89-
use tokio::net::unix::{OwnedReadHalf, OwnedWriteHalf};
9089
use tokio::net::UnixStream;
90+
use tokio::net::unix::{OwnedReadHalf, OwnedWriteHalf};
9191
use tokio_util::codec::{FramedRead, FramedWrite};
9292

9393
pub mod codec;
@@ -559,8 +559,11 @@ mod test {
559559
#[test]
560560
fn serialize_custom_msg_notification() {
561561
let msg = CustomMsgNotification {
562-
peer_id : PublicKey::from_str("0364aeb75519be29d1af7b8cc6232dbda9fdabb79b66e4e1f6a223750954db210b").unwrap(),
563-
payload : String::from("941746573749")
562+
peer_id: PublicKey::from_str(
563+
"0364aeb75519be29d1af7b8cc6232dbda9fdabb79b66e4e1f6a223750954db210b",
564+
)
565+
.unwrap(),
566+
payload: String::from("941746573749"),
564567
};
565568

566569
let notification = Notification::CustomMsg(msg);
@@ -576,14 +579,16 @@ mod test {
576579
}
577580
)
578581
);
579-
580582
}
581583

582584
#[test]
583585
fn serialize_block_added_notification() {
584586
let block_added = BlockAddedNotification {
585-
hash : crate::primitives::Sha256::from_str("000000000000000000000acab8abe0c67a52ed7e5a90a19c64930ff11fa84eca").unwrap(),
586-
height : 830702
587+
hash: crate::primitives::Sha256::from_str(
588+
"000000000000000000000acab8abe0c67a52ed7e5a90a19c64930ff11fa84eca",
589+
)
590+
.unwrap(),
591+
height: 830702,
587592
};
588593

589594
let notification = Notification::BlockAdded(block_added);
@@ -613,6 +618,6 @@ mod test {
613618
}
614619
});
615620

616-
let _ : Notification = serde_json::from_value(connect_json).unwrap();
621+
let _: Notification = serde_json::from_value(connect_json).unwrap();
617622
}
618623
}

cln-rpc/src/primitives.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Primitive types representing [`Amount`]s, [`PublicKey`]s, ...
22
use anyhow::Context;
3-
use anyhow::{anyhow, Error, Result};
3+
use anyhow::{Error, Result, anyhow};
44
use bitcoin::hashes::Hash as BitcoinHash;
55
use serde::{Deserialize, Serialize};
66
use serde::{Deserializer, Serializer};

plugins/bip353-plugin/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use cln_plugin::{messages::ProxyInfo, Plugin};
1+
use cln_plugin::{Plugin, messages::ProxyInfo};
22

33
pub fn get_proxy(plugin: Plugin<()>) -> Option<ProxyInfo> {
44
match plugin.configuration().always_use_proxy {

plugins/bip353-plugin/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use std::time::Duration;
33
use anyhow::anyhow;
44
use bitcoin::hex::DisplayHex;
55
use bitcoin_payment_instructions::{
6-
hrn_resolution::HumanReadableName, http_resolver::HTTPHrnResolver, PaymentInstructions,
7-
PaymentMethod, PossiblyResolvedPaymentMethod,
6+
PaymentInstructions, PaymentMethod, PossiblyResolvedPaymentMethod,
7+
hrn_resolution::HumanReadableName, http_resolver::HTTPHrnResolver,
88
};
99
use cln_plugin::{Builder, Plugin, RpcMethodBuilder};
1010
use serde::Serialize;

plugins/currencyrate-plugin/src/main.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use anyhow::anyhow;
22
use cln_plugin::options::StringArrayConfigOption;
33
use cln_plugin::{Builder, ConfiguredPlugin, Plugin, RpcMethodBuilder};
44
use cln_rpc::ClnRpc;
5-
use serde_json::{json, Value};
5+
use serde_json::{Value, json};
66
use std::net::{IpAddr, SocketAddr};
77
use std::path::Path;
88
use std::str::FromStr;
@@ -190,7 +190,10 @@ async fn currencyrate(plugin: Plugin<PluginState>, args: Value) -> Result<Value,
190190
}
191191
}
192192

193-
async fn listcurrencyrates(plugin: Plugin<PluginState>, args: Value) -> Result<Value, anyhow::Error> {
193+
async fn listcurrencyrates(
194+
plugin: Plugin<PluginState>,
195+
args: Value,
196+
) -> Result<Value, anyhow::Error> {
194197
let currency = match args {
195198
Value::Array(values) => {
196199
let currency = values

plugins/examples/cln-plugin-startup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use cln_plugin::options::{
77
DefaultStringArrayConfigOption, IntegerArrayConfigOption, IntegerConfigOption,
88
StringArrayConfigOption,
99
};
10-
use cln_plugin::{messages, Builder, Error, HookBuilder, Plugin};
10+
use cln_plugin::{Builder, Error, HookBuilder, Plugin, messages};
1111

1212
const TEST_NOTIF_TAG: &str = "test_custom_notification";
1313

plugins/examples/cln-subscribe-wildcard.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/// This plug-in subscribes to the wildcard-notifications
22
/// and creates a corresponding log-entry
3-
43
use anyhow::Result;
54
use cln_plugin::{Builder, Plugin};
65

@@ -14,21 +13,15 @@ async fn main() -> Result<()> {
1413
.await?;
1514

1615
match configured {
17-
Some(p) => p.join().await?,
18-
None => return Ok(()) // cln was started with --help
16+
Some(p) => p.join().await?,
17+
None => return Ok(()), // cln was started with --help
1918
};
2019

2120
Ok(())
2221
}
2322

24-
async fn handle_wildcard_notification(_plugin: Plugin<()>, value : serde_json::Value) -> Result<()> {
25-
let notification_type : String = value
26-
.as_object()
27-
.unwrap()
28-
.keys()
29-
.next()
30-
.unwrap()
31-
.into();
23+
async fn handle_wildcard_notification(_plugin: Plugin<()>, value: serde_json::Value) -> Result<()> {
24+
let notification_type: String = value.as_object().unwrap().keys().next().unwrap().into();
3225

3326
log::info!("Received notification {}", notification_type);
3427
Ok(())

plugins/grpc-plugin/src/main.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyhow::{Context, Result};
22
use cln_grpc::pb::node_server::NodeServer;
3-
use cln_plugin::{options, Builder, Plugin};
3+
use cln_plugin::{Builder, Plugin, options};
44
use cln_rpc::notifications::Notification;
55
use std::net::SocketAddr;
66
use std::path::PathBuf;
@@ -30,10 +30,12 @@ const OPTION_GRPC_HOST: options::DefaultStringConfigOption =
3030
"Which host should the grpc listen for incomming connections?",
3131
);
3232

33-
const OPTION_GRPC_MSG_BUFFER_SIZE : options::DefaultIntegerConfigOption = options::ConfigOption::new_i64_with_default(
34-
"grpc-msg-buffer-size",
35-
1024,
36-
"Number of notifications which can be stored in the grpc message buffer. Notifications can be skipped if this buffer is full");
33+
const OPTION_GRPC_MSG_BUFFER_SIZE: options::DefaultIntegerConfigOption =
34+
options::ConfigOption::new_i64_with_default(
35+
"grpc-msg-buffer-size",
36+
1024,
37+
"Number of notifications which can be stored in the grpc message buffer. Notifications can be skipped if this buffer is full",
38+
);
3739

3840
#[tokio::main(flavor = "current_thread")]
3941
async fn main() -> Result<()> {

0 commit comments

Comments
 (0)