From d2d9754df0fdb8986d06dbc258c0d92188e56cd1 Mon Sep 17 00:00:00 2001 From: Chris Beck Date: Fri, 5 Dec 2025 23:22:02 -0700 Subject: [PATCH] commit a rustfmt toml and merge imports --- rustfmt.toml | 4 ++++ signal-gateway-bin/src/main.rs | 3 +-- signal-gateway/src/concurrent_map.rs | 3 +-- signal-gateway/src/gateway/log_buffer.rs | 3 +-- signal-gateway/src/gateway/log_handler.rs | 8 +++++--- signal-gateway/src/gateway/mod.rs | 6 ++---- signal-gateway/src/gateway/rate_limiter_set.rs | 6 ++++-- signal-gateway/src/gateway/route.rs | 6 ++++-- signal-gateway/src/signal_jsonrpc.rs | 4 +--- signal-gateway/src/transports/ipc.rs | 6 ++---- signal-gateway/src/transports/stream_codec.rs | 6 ++++-- signal-gateway/src/transports/tcp.rs | 3 +-- 12 files changed, 30 insertions(+), 28 deletions(-) create mode 100644 rustfmt.toml diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..d1db130 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,4 @@ +edition = "2024" + +# Merge imports from the same crate into one use statement +imports_granularity = "Crate" diff --git a/signal-gateway-bin/src/main.rs b/signal-gateway-bin/src/main.rs index 49188fe..483afeb 100644 --- a/signal-gateway-bin/src/main.rs +++ b/signal-gateway-bin/src/main.rs @@ -4,8 +4,7 @@ use conf::{Conf, Subcommands}; use hyper::service::service_fn; -use hyper_util::rt::TokioIo; -use hyper_util::server::conn::auto; +use hyper_util::{rt::TokioIo, server::conn::auto}; use signal_gateway::{Gateway, GatewayConfig}; use std::{net::SocketAddr, sync::Arc, time::Duration}; use tokio::net::TcpListener; diff --git a/signal-gateway/src/concurrent_map.rs b/signal-gateway/src/concurrent_map.rs index 2cebf3f..942432f 100644 --- a/signal-gateway/src/concurrent_map.rs +++ b/signal-gateway/src/concurrent_map.rs @@ -4,8 +4,7 @@ //! where values already exist, using a read lock first before falling back to a //! write lock for insertions. -use std::collections::HashMap; -use std::hash::Hash; +use std::{collections::HashMap, hash::Hash}; use tokio::sync::RwLock; /// A concurrent hash map that uses read-preferring locking. diff --git a/signal-gateway/src/gateway/log_buffer.rs b/signal-gateway/src/gateway/log_buffer.rs index e39a580..a01654f 100644 --- a/signal-gateway/src/gateway/log_buffer.rs +++ b/signal-gateway/src/gateway/log_buffer.rs @@ -2,8 +2,7 @@ //! //! Wraps a circular buffer with a synchronous mutex for fast, blocking access. -use crate::circular_buffer::CircularBuffer; -use crate::log_message::LogMessage; +use crate::{circular_buffer::CircularBuffer, log_message::LogMessage}; use std::sync::Mutex; /// A thread-safe circular buffer for log messages. diff --git a/signal-gateway/src/gateway/log_handler.rs b/signal-gateway/src/gateway/log_handler.rs index ee82856..73321f2 100644 --- a/signal-gateway/src/gateway/log_handler.rs +++ b/signal-gateway/src/gateway/log_handler.rs @@ -1,6 +1,8 @@ -use super::log_buffer::LogBuffer; -use super::route::{Destination, Limit, Route}; -use super::{LimitResult, Limiter, LimiterSet, SignalAlertMessage, Summary}; +use super::{ + LimitResult, Limiter, LimiterSet, SignalAlertMessage, Summary, + log_buffer::LogBuffer, + route::{Destination, Limit, Route}, +}; use crate::{ concurrent_map::ConcurrentMap, log_format::LogFormatConfig, diff --git a/signal-gateway/src/gateway/mod.rs b/signal-gateway/src/gateway/mod.rs index 5b15310..8fdbae3 100644 --- a/signal-gateway/src/gateway/mod.rs +++ b/signal-gateway/src/gateway/mod.rs @@ -20,8 +20,7 @@ use http::{Method, Request, Response, StatusCode}; use http_body::Body; use http_body_util::BodyExt; use prometheus_http_client::{AlertStatus, ExtractLabels}; -use std::time::Duration; -use std::{collections::HashMap, fmt::Write, net::SocketAddr, path::PathBuf}; +use std::{collections::HashMap, fmt::Write, net::SocketAddr, path::PathBuf, time::Duration}; use tokio::{ join, sync::{ @@ -29,8 +28,7 @@ use tokio::{ mpsc::{UnboundedReceiver, UnboundedSender, unbounded_channel}, }, }; -use tokio_util::bytes::Buf; -use tokio_util::sync::CancellationToken; +use tokio_util::{bytes::Buf, sync::CancellationToken}; use tracing::{debug, error, info, warn}; mod log_buffer; diff --git a/signal-gateway/src/gateway/rate_limiter_set.rs b/signal-gateway/src/gateway/rate_limiter_set.rs index 81fe387..2a1a1be 100644 --- a/signal-gateway/src/gateway/rate_limiter_set.rs +++ b/signal-gateway/src/gateway/rate_limiter_set.rs @@ -1,7 +1,9 @@ //! Rate limiter set for managing per-route rate limiting. -use crate::log_message::{LogMessage, Origin}; -use crate::rate_limiter::Limiter; +use crate::{ + log_message::{LogMessage, Origin}, + rate_limiter::Limiter, +}; use std::collections::HashMap; /// Result of evaluating a limiter set. diff --git a/signal-gateway/src/gateway/route.rs b/signal-gateway/src/gateway/route.rs index d9c097d..606f728 100644 --- a/signal-gateway/src/gateway/route.rs +++ b/signal-gateway/src/gateway/route.rs @@ -4,8 +4,10 @@ //! and destination overrides. use super::rate_limiter_set::LimiterSet; -use crate::log_message::{Level, LogFilter}; -use crate::rate_limiter::{Limiter, RateThreshold}; +use crate::{ + log_message::{Level, LogFilter}, + rate_limiter::{Limiter, RateThreshold}, +}; use serde::Deserialize; /// A rate limit rule for suppressing repeated alerts. diff --git a/signal-gateway/src/signal_jsonrpc.rs b/signal-gateway/src/signal_jsonrpc.rs index 5bdc02f..744821c 100644 --- a/signal-gateway/src/signal_jsonrpc.rs +++ b/signal-gateway/src/signal_jsonrpc.rs @@ -1,9 +1,7 @@ //! This copied from https://github.com/AsamK/signal-cli/blob/f9a36c6e0404d06bd396b24b5ea699e49ed29b89/client/src/jsonrpc.rs #![allow(clippy::too_many_arguments)] -use jsonrpsee::async_client::ClientBuilder; -use jsonrpsee::core::client::SubscriptionClientT; -use jsonrpsee::proc_macros::rpc; +use jsonrpsee::{async_client::ClientBuilder, core::client::SubscriptionClientT, proc_macros::rpc}; use serde::Deserialize; use serde_json::Value; use tokio::net::ToSocketAddrs; diff --git a/signal-gateway/src/transports/ipc.rs b/signal-gateway/src/transports/ipc.rs index c5b5800..14f9630 100644 --- a/signal-gateway/src/transports/ipc.rs +++ b/signal-gateway/src/transports/ipc.rs @@ -1,13 +1,11 @@ -use std::io::Error; -use std::path::Path; +use std::{io::Error, path::Path}; use futures_util::stream::StreamExt; use jsonrpsee::core::client::{TransportReceiverT, TransportSenderT}; use tokio::net::UnixStream; use tokio_util::codec::Decoder; -use super::stream_codec::StreamCodec; -use super::{Receiver, Sender}; +use super::{Receiver, Sender, stream_codec::StreamCodec}; /// Connect to a JSON-RPC server via Unix domain socket. pub async fn connect( diff --git a/signal-gateway/src/transports/stream_codec.rs b/signal-gateway/src/transports/stream_codec.rs index 341fa52..60079a4 100644 --- a/signal-gateway/src/transports/stream_codec.rs +++ b/signal-gateway/src/transports/stream_codec.rs @@ -1,8 +1,10 @@ //! This copied from https://github.com/AsamK/signal-cli/blob/f9a36c6e0404d06bd396b24b5ea699e49ed29b89/client/src/jsonrpc.rs use std::{io, str}; -use tokio_util::bytes::BytesMut; -use tokio_util::codec::{Decoder, Encoder}; +use tokio_util::{ + bytes::BytesMut, + codec::{Decoder, Encoder}, +}; type Separator = u8; diff --git a/signal-gateway/src/transports/tcp.rs b/signal-gateway/src/transports/tcp.rs index ae80759..8934a7f 100644 --- a/signal-gateway/src/transports/tcp.rs +++ b/signal-gateway/src/transports/tcp.rs @@ -5,8 +5,7 @@ use jsonrpsee::core::client::{TransportReceiverT, TransportSenderT}; use tokio::net::{TcpStream, ToSocketAddrs}; use tokio_util::codec::Decoder; -use super::stream_codec::StreamCodec; -use super::{Receiver, Sender}; +use super::{Receiver, Sender, stream_codec::StreamCodec}; /// Connect to a JSON-RPC TCP server. pub async fn connect(