diff options
author | Marcel Müller <neikos@neikos.email> | 2024-03-20 18:02:19 +0100 |
---|---|---|
committer | Marcel Müller <neikos@neikos.email> | 2024-03-20 18:02:19 +0100 |
commit | 861502c7efad19667b4d97b8a5b0772bbbfc5b3d (patch) | |
tree | fbf6fc68878769c85a0096d93eb7cdf8337d59dc | |
parent | 82b6f333a92a03107ac7c8639551914c9675a0e9 (diff) |
Inline the ProtocolLevel struct to MConnect
Signed-off-by: Marcel Müller <neikos@neikos.email>
-rw-r--r-- | mqtt-format/src/v5/level.rs | 30 | ||||
-rw-r--r-- | mqtt-format/src/v5/mod.rs | 1 | ||||
-rw-r--r-- | mqtt-format/src/v5/packets/connect.rs | 20 |
3 files changed, 19 insertions, 32 deletions
diff --git a/mqtt-format/src/v5/level.rs b/mqtt-format/src/v5/level.rs deleted file mode 100644 index 7e54eef..0000000 --- a/mqtt-format/src/v5/level.rs +++ /dev/null @@ -1,30 +0,0 @@ -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. -// - -use winnow::error::ErrMode; -use winnow::error::ParserError; -use winnow::Bytes; - -use super::MResult; - -#[derive(Debug, Copy, Clone, PartialEq)] -pub enum ProtocolLevel { - V3, - V5, -} - -impl ProtocolLevel { - pub fn parse(input: &mut &Bytes) -> MResult<Self> { - match winnow::binary::u8(input)? { - 3 => Ok(Self::V3), - 5 => Ok(Self::V5), - _ => Err(ErrMode::from_error_kind( - input, - winnow::error::ErrorKind::Verify, - )), - } - } -} diff --git a/mqtt-format/src/v5/mod.rs b/mqtt-format/src/v5/mod.rs index f393810..1152790 100644 --- a/mqtt-format/src/v5/mod.rs +++ b/mqtt-format/src/v5/mod.rs @@ -38,7 +38,6 @@ pub mod bytes; pub mod fixed_header; pub mod integers; -pub mod level; pub mod packets; pub mod properties; pub mod reason_code; diff --git a/mqtt-format/src/v5/packets/connect.rs b/mqtt-format/src/v5/packets/connect.rs index fa90f77..61a9901 100644 --- a/mqtt-format/src/v5/packets/connect.rs +++ b/mqtt-format/src/v5/packets/connect.rs @@ -13,7 +13,6 @@ use winnow::Parser; use crate::v5::bytes::parse_binary_data; use crate::v5::fixed_header::QualityOfService; use crate::v5::integers::parse_u16; -use crate::v5::level::ProtocolLevel; use crate::v5::strings::parse_string; use crate::v5::variable_header::AuthenticationData; use crate::v5::variable_header::AuthenticationMethod; @@ -183,3 +182,22 @@ crate::v5::properties::define_properties! { correlation_data: CorrelationData<'i>, } } + +#[derive(Debug, Copy, Clone, PartialEq)] +pub enum ProtocolLevel { + V3, + V5, +} + +impl ProtocolLevel { + pub fn parse(input: &mut &Bytes) -> MResult<Self> { + match winnow::binary::u8(input)? { + 3 => Ok(Self::V3), + 5 => Ok(Self::V5), + _ => Err(ErrMode::from_error_kind( + input, + winnow::error::ErrorKind::Verify, + )), + } + } +} |