Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Housekeeping #206

Merged
merged 5 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ repos:
- id: codespell
args: [--ignore-words=.codespellignore]
- repo: https://github.com/sirosen/check-jsonschema
rev: 0.23.2
rev: 0.23.3
hooks:
- id: check-github-actions
- id: check-github-workflows
Expand All @@ -57,7 +57,7 @@ repos:
- markdown
# https://reuse.software
- repo: https://github.com/fsfe/reuse-tool
rev: v2.0.0
rev: v2.1.0
hooks:
- id: reuse
- repo: https://github.com/doublify/pre-commit-rust
Expand Down
20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,33 @@ all-features = true
# <https://users.rust-lang.org/t/psa-please-specify-precise-dependency-versions-in-cargo-toml/71277>

[dependencies]
async-trait = "0.1.68"
async-trait = "0.1.72"
byteorder = "1.4.3"
bytes = "1.4.0"
futures = { version = "0.3.28", optional = true }
futures-util = { version = "0.3.28", optional = true, default-features = false }
log = "0.4.17"
smallvec = { version = "1.10.0", default-features = false }
socket2 = { version = "0.5.2", optional = true, default-features = false }
tokio = { version = "1.27.0", default-features = false }
log = "0.4.19"
smallvec = { version = "1.11.0", default-features = false }
socket2 = { version = "0.5.3", optional = true, default-features = false }
tokio = { version = "1.29.1", default-features = false }
# 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.7", default-features = false, features = [
tokio-util = { version = "0.7.8", default-features = false, features = [
"codec",
] }

[dev-dependencies]
anyhow = "1.0.70"
anyhow = "1.0.72"
env_logger = "0.10.0"
futures = "0.3.28"
tokio = { version = "1.27.0", default-features = false, features = [
tokio = { version = "1.29.1", default-features = false, features = [
"macros",
"rt-multi-thread",
"time",
] }
tokio-serial = { version = "5.4.4", default-features = false }
rustls-pemfile = "1.0.2"
tokio-rustls = "0.24.0"
rustls-pemfile = "1.0.3"
tokio-rustls = "0.24.1"
pkcs8 = { version = "0.10.2", features = ["encryption", "pem", "std"] }
pem = "2.0.1"
webpki = "0.22.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/tcp-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ async fn client_context(socket_addr: SocketAddr) {
println!("CLIENT: Reading 2 input registers...");
let response = ctx.read_input_registers(0x00, 2).await.unwrap();
println!("CLIENT: The result is '{response:?}'");
assert_eq!(response, vec![1234, 5678]);
assert_eq!(response, [1234, 5678]);

println!("CLIENT: Writing 2 holding registers...");
ctx.write_multiple_registers(0x01, &[7777, 8888])
Expand All @@ -193,7 +193,7 @@ async fn client_context(socket_addr: SocketAddr) {
println!("CLIENT: Reading 4 holding registers...");
let response = ctx.read_holding_registers(0x00, 4).await.unwrap();
println!("CLIENT: The result is '{response:?}'");
assert_eq!(response, vec![10, 7777, 8888, 40]);
assert_eq!(response, [10, 7777, 8888, 40]);

// Now we try to read with an invalid register address.
// This should return a Modbus exception response with the code
Expand Down
2 changes: 1 addition & 1 deletion examples/tls-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = rustls::ClientConfig::builder()
.with_safe_defaults()
.with_root_certificates(root_cert_store)
.with_single_cert(certs, keys.remove(0))
.with_client_auth_cert(certs, keys.remove(0))
.map_err(|err| io::Error::new(io::ErrorKind::InvalidInput, err))?;
let connector = TlsConnector::from(Arc::new(config));

Expand Down
6 changes: 3 additions & 3 deletions examples/tls-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ async fn client_context(socket_addr: SocketAddr) {
let config = rustls::ClientConfig::builder()
.with_safe_defaults()
.with_root_certificates(root_cert_store)
.with_single_cert(certs, keys.remove(0))
.with_client_auth_cert(certs, keys.remove(0))
.map_err(|err| io::Error::new(io::ErrorKind::InvalidInput, err))
.unwrap();
let connector = TlsConnector::from(Arc::new(config));
Expand All @@ -287,7 +287,7 @@ async fn client_context(socket_addr: SocketAddr) {
println!("CLIENT: Reading 2 input registers...");
let response = ctx.read_input_registers(0x00, 2).await.unwrap();
println!("CLIENT: The result is '{response:?}'");
assert_eq!(response, vec![1234, 5678]);
assert_eq!(response, [1234, 5678]);

println!("CLIENT: Writing 2 holding registers...");
ctx.write_multiple_registers(0x01, &[7777, 8888])
Expand All @@ -298,7 +298,7 @@ async fn client_context(socket_addr: SocketAddr) {
println!("CLIENT: Reading 4 holding registers...");
let response = ctx.read_holding_registers(0x00, 4).await.unwrap();
println!("CLIENT: The result is '{response:?}'");
assert_eq!(response, vec![10, 7777, 8888, 40]);
assert_eq!(response, [10, 7777, 8888, 40]);

// Now we try to read with an invalid register address.
// This should return a Modbus exception response with the code
Expand Down
2 changes: 0 additions & 2 deletions src/client/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

//! Synchronous Modbus client

#![allow(missing_docs)]

#[cfg(feature = "rtu-sync")]
pub mod rtu;

Expand Down
1 change: 0 additions & 1 deletion src/codec/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-FileCopyrightText: Copyright (c) 2017-2023 slowtec GmbH <post@slowtec.de>
// SPDX-License-Identifier: MIT OR Apache-2.0

#![allow(deprecated)]
#[cfg(feature = "rtu")]
pub(crate) mod rtu;

Expand Down
4 changes: 2 additions & 2 deletions src/codec/rtu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,10 @@ mod tests {

#[test]
fn test_calc_crc() {
let msg = vec![0x01, 0x03, 0x08, 0x2B, 0x00, 0x02];
let msg = [0x01, 0x03, 0x08, 0x2B, 0x00, 0x02];
assert_eq!(calc_crc(&msg), 0xB663);

let msg = vec![0x01, 0x03, 0x04, 0x00, 0x20, 0x00, 0x00];
let msg = [0x01, 0x03, 0x04, 0x00, 0x20, 0x00, 0x00];
assert_eq!(calc_crc(&msg), 0xFBF9);
}

Expand Down
7 changes: 0 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
#![warn(rust_2021_compatibility)]
#![warn(missing_debug_implementations)]
#![warn(unreachable_pub)]
#![warn(clippy::cast_lossless)]
// TODO (v0.6): Decorate functions with #[must_use]
//#![warn(clippy::must_use_candidate)]
#![cfg_attr(not(test), warn(unsafe_code))]
#![warn(clippy::pedantic)]
#![warn(clippy::clone_on_ref_ptr)]
Expand All @@ -16,11 +13,7 @@
#![allow(clippy::module_name_repetitions)]
#![allow(clippy::wildcard_imports)] // TODO
#![allow(clippy::missing_errors_doc)] // TODO
#![cfg_attr(not(test), warn(clippy::panic_in_result_fn))]
#![cfg_attr(not(test), warn(clippy::cast_possible_truncation))]
#![warn(rustdoc::broken_intra_doc_links)]
#![cfg_attr(not(debug_assertions), deny(warnings))]
#![cfg_attr(not(debug_assertions), deny(clippy::used_underscore_binding))]
#![doc = include_str!("../README.md")]

pub mod prelude;
Expand Down