From f36f92526908a5a21d46e020653d09b5a585f3fa Mon Sep 17 00:00:00 2001 From: threema-donat <129288638+threema-donat@users.noreply.github.com> Date: Tue, 14 May 2024 08:15:43 +0200 Subject: [PATCH] Add rustfmt config and apply new rules in code and CI --- .github/workflows/ci.yml | 2 +- rustfmt.toml | 1 + src/influxdb.rs | 9 +++++---- src/server.rs | 27 +++++++++++++++------------ 4 files changed, 22 insertions(+), 17 deletions(-) create mode 100644 rustfmt.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5aff0a..4a47940 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@v1 with: - toolchain: $RUST_VERSION + toolchain: nightly components: rustfmt - run: cargo fmt --all --check diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..c3c8c37 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +imports_granularity = "Crate" diff --git a/src/influxdb.rs b/src/influxdb.rs index c07d028..db3d8e3 100644 --- a/src/influxdb.rs +++ b/src/influxdb.rs @@ -1,11 +1,12 @@ use std::str::from_utf8; use base64::{engine::general_purpose::STANDARD as BASE64, Engine}; -use reqwest::header::{AUTHORIZATION, CONTENT_TYPE}; -use reqwest::{Body, Client, StatusCode}; +use reqwest::{ + header::{AUTHORIZATION, CONTENT_TYPE}, + Body, Client, StatusCode, +}; -use crate::errors::InfluxdbError; -use crate::http_client::make_client; +use crate::{errors::InfluxdbError, http_client::make_client}; /// InfluxDB client. #[derive(Debug)] diff --git a/src/server.rs b/src/server.rs index 63deb88..cd14ef4 100644 --- a/src/server.rs +++ b/src/server.rs @@ -1,12 +1,17 @@ use std::{borrow::Cow, collections::HashMap, convert::Into, net::SocketAddr, sync::Arc}; -use a2::client::{Client as ApnsClient, Endpoint}; -use a2::CollapseId; -use axum::body::Body; -use axum::http::{Request, StatusCode}; -use axum::response::Response; -use axum::Router; -use axum::{extract::State, routing::post}; +use a2::{ + client::{Client as ApnsClient, Endpoint}, + CollapseId, +}; +use axum::{ + body::Body, + extract::State, + http::{Request, StatusCode}, + response::Response, + routing::post, + Router, +}; use data_encoding::HEXLOWER_PERMISSIVE; use futures::future::{BoxFuture, FutureExt}; use reqwest::{header::CONTENT_TYPE, Client as HttpClient}; @@ -15,17 +20,15 @@ use tower::ServiceBuilder; use tower_http::trace::{self, TraceLayer}; use tracing::Level; -use crate::errors::PushRelayError; -use crate::push::fcm::FcmStateConfig; -use crate::push::hms::HmsStateConfig; use crate::{ config::{Config, ThreemaGatewayConfig}, - errors::{InfluxdbError, SendPushError, ServiceError}, + errors::{InfluxdbError, PushRelayError, SendPushError, ServiceError}, http_client, influxdb::Influxdb, push::{ apns, fcm, - hms::{self, HmsContext}, + fcm::FcmStateConfig, + hms::{self, HmsContext, HmsStateConfig}, threema_gateway, ApnsToken, FcmToken, HmsToken, PushToken, }, ThreemaGatewayPrivateKey,