diff options
author | Marcel Müller <neikos@neikos.email> | 2024-03-20 17:47:11 +0100 |
---|---|---|
committer | Marcel Müller <neikos@neikos.email> | 2024-03-20 17:47:11 +0100 |
commit | 08eaade93cd54a5f9f1d8ea19da7a0d4fcc8c851 (patch) | |
tree | 086d75b387e1b2365c7b40f8a320f280c9446217 | |
parent | db568c4ce88ff046e4011bcc8f3a5f06401c75f3 (diff) |
Add parse_complete method for MqttPacket
Signed-off-by: Marcel Müller <neikos@neikos.email>
-rw-r--r-- | mqtt-format/src/v5/packets/mod.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/mqtt-format/src/v5/packets/mod.rs b/mqtt-format/src/v5/packets/mod.rs index 0de3b41..6b7737c 100644 --- a/mqtt-format/src/v5/packets/mod.rs +++ b/mqtt-format/src/v5/packets/mod.rs @@ -4,6 +4,8 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. // +use winnow::error::ContextError; +use winnow::error::ErrMode; use winnow::Bytes; use winnow::Parser; @@ -96,6 +98,10 @@ impl<'i> MqttPacket<'i> { }) .parse_next(input) } + + pub fn parse_complete(input: &'i [u8]) -> Result<Self, ErrMode<ContextError>> { + Self::parse(&mut Bytes::new(input)) + } } macro_rules! impl_try_from_packet { |