diff --git a/Cargo.toml b/Cargo.toml index e44e709..07fdc34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,8 +9,11 @@ license = "MIT" description = "macros and helpers for parsing netlink messages" readme = "README.md" +[features] +serde = ["dep:serde"] [dependencies] byteorder = "1.3.2" pastey = "0.1.0" +serde = { version = "1", features = ["derive"], optional = true } thiserror = "2" diff --git a/src/errors.rs b/src/errors.rs index 2a664bf..7dc039d 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,8 +1,6 @@ // SPDX-License-Identifier: MIT -use thiserror::Error; - -#[derive(Debug, Error)] +#[derive(Debug, thiserror::Error)] #[non_exhaustive] pub enum EncodeError { #[error(transparent)] @@ -23,7 +21,7 @@ impl From for EncodeError { } } -#[derive(Debug, Error)] +#[derive(Debug, thiserror::Error)] #[non_exhaustive] pub enum DecodeError { #[error( @@ -58,6 +56,9 @@ pub enum DecodeError { Other(#[from] Box), } +unsafe impl Send for DecodeError {} +unsafe impl Sync for DecodeError {} + impl From<&str> for DecodeError { fn from(msg: &str) -> Self { let error: Box = msg.to_string().into(); diff --git a/src/nla.rs b/src/nla.rs index 1b7f8e9..0094afd 100644 --- a/src/nla.rs +++ b/src/nla.rs @@ -181,6 +181,7 @@ impl + AsMut<[u8]> + ?Sized> NlaBuffer<&mut T> { } #[derive(Debug, PartialEq, Eq, Clone)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DefaultNla { kind: u16, value: Vec,