diff --git a/CHANGELOG.md b/CHANGELOG.md index cc5f062e..ec93922f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.6.0 (Unreleased) + +- Features: Replace "sync" with "rtu-sync" and "tcp-sync" respectively + ## v0.5.2 (2021-12-05) - Fix (RTU): Wrong byte count offset when writing multiple coils/registers diff --git a/Cargo.toml b/Cargo.toml index 439ed57c..d8a4c0a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,20 +25,22 @@ socket2 = { version = "0.4.4", optional = true, default-features = false } tokio = { version = "1.17.0", default-features = false } # Disable default-features to exclude unused dependency on libudev tokio-serial = { version = "5.4.1", optional = true, default-features = false } -tokio-util = { version = "0.7.0", features = ["codec"] } +tokio-util = { version = "0.7.0", default-features = false, features = ["codec"] } [dev-dependencies] env_logger = "0.9.0" futures = "0.3.21" -tokio = { version = "1.17.0", features = ["net", "macros", "io-util", "rt", "time"] } +tokio = { version = "1.17.0", features = ["net", "macros", "io-util", "rt-multi-thread", "time"] } [features] -default = ["tcp", "rtu"] -rtu = ["tokio-serial", "futures-util/sink"] +default = ["rtu", "tcp"] +rtu = ["futures-util/sink"] tcp = ["tokio/net", "futures-util/sink"] -sync = ["tokio/rt"] -server = ["futures", "socket2/all", "tokio/macros", "tokio/rt", "tokio/rt-multi-thread"] -tcp-server-unstable = ["tcp", "server"] +rtu-sync = ["rtu", "tokio-serial"] +tcp-sync = ["tcp"] +server = ["futures"] +rtu-server = ["rtu", "server", "tokio/macros", "tokio-serial"] +tcp-server-unstable = ["tcp", "server", "socket2/all", "tokio/macros", "tokio/rt-multi-thread"] [badges] maintenance = { status = "actively-developed" } @@ -46,7 +48,7 @@ maintenance = { status = "actively-developed" } [[example]] name = "rtu-client-sync" path = "examples/rtu-client-sync.rs" -required-features = ["rtu", "sync"] +required-features = ["rtu-sync"] [[example]] name = "rtu-client" @@ -56,7 +58,7 @@ required-features = ["rtu"] [[example]] name = "rtu-server" path = "examples/rtu-server.rs" -required-features = ["rtu", "server"] +required-features = ["rtu-server"] [[example]] name = "tcp-client-custom-fn" @@ -66,7 +68,7 @@ required-features = ["tcp"] [[example]] name = "tcp-client-sync" path = "examples/tcp-client-sync.rs" -required-features = ["tcp", "sync"] +required-features = ["tcp-sync"] [[example]] name = "tcp-client" @@ -76,4 +78,4 @@ required-features = ["tcp"] [[example]] name = "tcp-server" path = "examples/tcp-server.rs" -required-features = ["tcp", "server", "tcp-server-unstable"] +required-features = ["tcp-server-unstable"] diff --git a/src/client/mod.rs b/src/client/mod.rs index 937c0dc9..3105b1df 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -9,15 +9,15 @@ use async_trait::async_trait; use crate::{frame::*, slave::*}; -#[cfg(feature = "sync")] -pub mod sync; - #[cfg(feature = "rtu")] pub mod rtu; #[cfg(feature = "tcp")] pub mod tcp; +#[cfg(any(feature = "rtu-sync", feature = "tcp-sync"))] +pub mod sync; + /// Transport independent asynchronous client trait #[async_trait] pub trait Client: SlaveContext + Send + Debug { diff --git a/src/client/sync/mod.rs b/src/client/sync/mod.rs index c08f3c8a..6b21c59a 100644 --- a/src/client/sync/mod.rs +++ b/src/client/sync/mod.rs @@ -1,14 +1,11 @@ //! Synchronous Modbus client -// TODO: Add missing documentation #![allow(missing_docs)] -/// RTU client connections -#[cfg(feature = "rtu")] +#[cfg(feature = "rtu-sync")] pub mod rtu; -/// TCP client connections -#[cfg(feature = "tcp")] +#[cfg(feature = "tcp-sync")] pub mod tcp; use super::{ diff --git a/src/lib.rs b/src/lib.rs index c2001ad1..6f8b6103 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -71,8 +71,8 @@ //! ## Sync TCP client //! //! ```rust,no_run -//! # #[cfg(all(feature = "tcp", feature = "sync"))] -//! # //FIXME: Run doc tests with `--features sync` to fix failure +//! # #[cfg(feature = "tcp-sync")] +//! # //FIXME: Run doc tests with `--features rtu-sync,tcp-sync` to fix failure //! pub fn main() -> Result<(), Box> { //! use tokio_modbus::prelude::*; //! @@ -114,8 +114,8 @@ //! ## Sync RTU client //! //! ```rust,no_run -//! # #[cfg(all(feature = "rtu", feature = "sync"))] -//! # //FIXME: Run doc tests with `--features sync` to fix failure +//! # #[cfg(feature = "rtu-sync")] +//! # //FIXME: Run doc tests with `--features rtu-sync,tcp-sync` to fix failure //! pub fn main() -> Result<(), Box> { //! use tokio_modbus::prelude::*; //! diff --git a/src/prelude.rs b/src/prelude.rs index 91ea8004..135ff036 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -29,6 +29,12 @@ pub mod tcp { #[cfg(feature = "server")] pub use crate::server; +#[allow(missing_docs)] +#[cfg(any(feature = "rtu-sync", feature = "tcp-sync"))] +pub mod sync { + pub use crate::client::sync::*; +} + /////////////////////////////////////////////////////////////////// /// Structs /////////////////////////////////////////////////////////////////// @@ -40,13 +46,13 @@ pub use crate::slave::{Slave, SlaveId}; /////////////////////////////////////////////////////////////////// pub use crate::client::{Client, Reader, Writer}; -#[cfg(feature = "sync")] +#[cfg(any(feature = "rtu-sync", feature = "tcp-sync"))] pub use crate::client::sync::Client as SyncClient; -#[cfg(feature = "sync")] +#[cfg(any(feature = "rtu-sync", feature = "tcp-sync"))] pub use crate::client::sync::Reader as SyncReader; -#[cfg(feature = "sync")] +#[cfg(any(feature = "rtu-sync", feature = "tcp-sync"))] pub use crate::client::sync::Writer as SyncWriter; pub use crate::slave::SlaveContext; diff --git a/src/server/mod.rs b/src/server/mod.rs index d71d5380..ad35ea7e 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -3,7 +3,7 @@ // TODO: Add missing documentation #![allow(missing_docs)] -#[cfg(feature = "rtu")] +#[cfg(feature = "rtu-server")] pub mod rtu; #[cfg(feature = "tcp-server-unstable")]