From f3a7e186d38ad7f4209e593ddcf7d6d0972dcc5e Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Thu, 24 Oct 2024 13:16:23 +0200 Subject: [PATCH] Add taplo config and pre-commit hook --- .deny.toml | 8 +------- .pre-commit-config.yaml | 5 +++++ .taplo.toml | 5 +++++ Cargo.toml | 30 +++++++----------------------- rust-toolchain.toml | 2 +- 5 files changed, 19 insertions(+), 31 deletions(-) create mode 100644 .taplo.toml diff --git a/.deny.toml b/.deny.toml index 624096ce..2c78831d 100644 --- a/.deny.toml +++ b/.deny.toml @@ -10,13 +10,7 @@ db-urls = ["https://github.com/rustsec/advisory-db"] yanked = "deny" [licenses] -allow = [ - "Apache-2.0", - "BSD-2-Clause", - "MIT", - "MPL-2.0", - "Unicode-DFS-2016", -] +allow = ["Apache-2.0", "BSD-2-Clause", "MIT", "MPL-2.0", "Unicode-DFS-2016"] [bans] # Multiple versions of dependencies are inevitable and cannot be avoided. diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2ddacba1..a213a0f5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -55,6 +55,11 @@ repos: types_or: - yaml - markdown + - repo: https://github.com/ComPWA/taplo-pre-commit + rev: v0.9.3 + hooks: + - id: taplo-format + - id: taplo-lint # https://reuse.software - repo: https://github.com/fsfe/reuse-tool rev: v4.0.3 diff --git a/.taplo.toml b/.taplo.toml new file mode 100644 index 00000000..c4a36875 --- /dev/null +++ b/.taplo.toml @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: Copyright (c) 2017-2024 slowtec GmbH +# SPDX-License-Identifier: CC0-1.0 + +[formatting] +column_width = 100 diff --git a/Cargo.toml b/Cargo.toml index 15b6de7d..1dfd1208 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,10 +5,7 @@ name = "tokio-modbus" description = "Tokio-based Modbus library" version = "0.15.0" -authors = [ - "slowtec GmbH ", - "Markus Kohlhase ", -] +authors = ["slowtec GmbH ", "Markus Kohlhase "] license = "MIT OR Apache-2.0" readme = "README.md" keywords = ["fieldbus", "modbus", "hardware", "automation"] @@ -37,18 +34,16 @@ thiserror = "1.0.58" tokio = { version = "1.35.1", default-features = false, features = ["io-util"] } # Disable default-features to exclude unused dependency on libudev tokio-serial = { version = "5.4.4", optional = true, default-features = false } -tokio-util = { version = "0.7.10", optional = true, default-features = false, features = [ - "codec", -] } +tokio-util = { version = "0.7.10", optional = true, default-features = false, features = ["codec"] } [dev-dependencies] anyhow = "1.0.86" env_logger = "0.11.5" futures = "0.3.30" tokio = { version = "1.35.1", default-features = false, features = [ - "macros", - "rt-multi-thread", - "time", + "macros", + "rt-multi-thread", + "time", ] } tokio-serial = { version = "5.4.4", default-features = false } rustls-pemfile = "2.1.2" @@ -60,23 +55,12 @@ rustls = { version = "0.23.12", default-features = false, features = ["std"] } [features] default = ["rtu", "tcp"] -rtu = [ - "dep:futures-core", - "futures-util/sink", - "dep:smallvec", - "dep:tokio-util", -] +rtu = ["dep:futures-core", "futures-util/sink", "dep:smallvec", "dep:tokio-util"] tcp = ["dep:futures-core", "futures-util/sink", "tokio/net", "dep:tokio-util"] rtu-sync = ["rtu", "sync", "dep:tokio-serial"] tcp-sync = ["tcp", "sync"] rtu-server = ["rtu", "server", "tokio/macros", "dep:tokio-serial"] -tcp-server = [ - "tcp", - "server", - "socket2/all", - "tokio/macros", - "tokio/rt-multi-thread", -] +tcp-server = ["tcp", "server", "socket2/all", "tokio/macros", "tokio/rt-multi-thread"] rtu-over-tcp-server = ["rtu", "tcp-server"] # The following features are internal and must not be used in dependencies. sync = ["dep:futures-core", "futures-util/sink", "tokio/time", "tokio/rt"] diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 4872fe3c..92feb76b 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -4,4 +4,4 @@ [toolchain] channel = "stable" profile = "minimal" -components = [ "rustfmt", "clippy" ] +components = ["rustfmt", "clippy"]