diff --git a/rodbus/README.md b/rodbus/README.md index e0ca7168..de90623a 100644 --- a/rodbus/README.md +++ b/rodbus/README.md @@ -22,7 +22,7 @@ A high-performance implementation of the [Modbus](http://modbus.org/) protocol u ## Function Codes -The [`client`](https://github.com/stepfunc/rodbus/blob/main/rodbus/examples/client.rs) and [`server`](https://github.com/stepfunc/rodbus/blob/main/rodbus/examples/server.rs) examples demonstrate simple +The [`client`](https://github.com/stepfunc/rodbus/blob/main/examples/client/src/main.rs) and [`server`](https://github.com/stepfunc/rodbus/blob/main/examples/server/src/main.rs) examples demonstrate simple usage of the API. The following function codes are supported: diff --git a/rodbus/src/decode.rs b/rodbus/src/decode.rs index 15339ab1..c7cd34ef 100644 --- a/rodbus/src/decode.rs +++ b/rodbus/src/decode.rs @@ -1,5 +1,5 @@ /// Controls the decoding of transmitted and received data at the application, frame, and physical layer -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Default)] #[cfg_attr( feature = "serialization", derive(serde::Serialize, serde::Deserialize) @@ -19,13 +19,14 @@ pub struct DecodeLevel { /// Controls how transmitted and received message at the application layer are decoded at the INFO log level /// /// Application-layer messages are referred to as Protocol Data Units (PDUs) in the specification. -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Default)] #[cfg_attr( feature = "serialization", derive(serde::Serialize, serde::Deserialize) )] pub enum AppDecodeLevel { /// Decode nothing + #[default] Nothing, /// Decode the function code only FunctionCode, @@ -41,13 +42,14 @@ pub enum AppDecodeLevel { /// called "ADUs" in the Modbus specification. /// /// On TCP, this is the MBAP decoding. On serial, this controls the serial line PDU. -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Default)] #[cfg_attr( feature = "serialization", derive(serde::Serialize, serde::Deserialize) )] pub enum FrameDecodeLevel { /// Decode nothing + #[default] Nothing, /// Decode the header Header, @@ -56,13 +58,14 @@ pub enum FrameDecodeLevel { } /// Controls how data transmitted at the physical layer (TCP, serial, etc) is logged -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Default)] #[cfg_attr( feature = "serialization", derive(serde::Serialize, serde::Deserialize) )] pub enum PhysDecodeLevel { /// Log nothing + #[default] Nothing, /// Log only the length of data that is sent and received Length, @@ -104,16 +107,6 @@ impl DecodeLevel { } } -impl Default for DecodeLevel { - fn default() -> Self { - Self { - app: AppDecodeLevel::Nothing, - frame: FrameDecodeLevel::Nothing, - physical: PhysDecodeLevel::Nothing, - } - } -} - impl From for DecodeLevel { fn from(pdu: AppDecodeLevel) -> Self { Self { @@ -157,12 +150,6 @@ impl AppDecodeLevel { } } -impl Default for AppDecodeLevel { - fn default() -> Self { - Self::Nothing - } -} - impl FrameDecodeLevel { pub(crate) fn enabled(&self) -> bool { self.header_enabled() @@ -185,12 +172,6 @@ impl FrameDecodeLevel { } } -impl Default for FrameDecodeLevel { - fn default() -> Self { - Self::Nothing - } -} - impl PhysDecodeLevel { pub(crate) fn enabled(&self) -> bool { self.length_enabled() @@ -212,9 +193,3 @@ impl PhysDecodeLevel { } } } - -impl Default for PhysDecodeLevel { - fn default() -> Self { - Self::Nothing - } -}