From ad9ca06bdab3063f566d016f1b586dfc2c58743b Mon Sep 17 00:00:00 2001 From: Tobias Maier Date: Sun, 18 Jan 2026 19:19:06 +0100 Subject: [PATCH] fix(transmission): avoid lifetime in FromBytesError by owning data Changed FromBytesError::InvalidBytes to take ownership of the byte slice by converting it to Vec. This removes the lifetime parameter from the enum, simplifying the API and preventing potential lifetime-related issues. The change ensures that error instances can be freely moved and stored without borrowing constraints. --- src/transmission.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/transmission.rs b/src/transmission.rs index d07b517..2eecb8f 100644 --- a/src/transmission.rs +++ b/src/transmission.rs @@ -45,7 +45,7 @@ impl Protocol300Transmission { error!("Failed to parse Protocol300 transmission: invalid byte sequence (length: {}, first byte: 0x{:02X})", bytes.len(), bytes.first().unwrap_or(&0x00)); - Err(FromBytesError::InvalidBytes(b)) + Err(FromBytesError::InvalidBytes(b.to_owned())) }, } } @@ -75,11 +75,11 @@ impl Protocol300Transmission { /// Errors that can occur when getting a Protocol 300 Transmission from bytes #[derive(Error, Debug, PartialEq, Eq)] -pub enum FromBytesError<'a>{ +pub enum FromBytesError{ #[error("Failed to parse message")] MessageParsing(#[from] message::MessageDecodingError), #[error("Invalid bytes in vec")] - InvalidBytes(&'a [u8]) + InvalidBytes(Vec) }