Skip to content

Commit

Permalink
Merge pull request #84 from dimpolo/error-serialize
Browse files Browse the repository at this point in the history
derive Serialize for de::Error and ser::Error
  • Loading branch information
ryan-summers committed Jul 24, 2024
2 parents 9327a14 + d6d1d9b commit a0dad18
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ ryu = "1.0.5"

[dependencies.heapless]
version = "0.8"
features = ["serde"]
optional = true

[dependencies.serde]
default-features = false
features = ["derive"]
version = "1.0.100"

[dependencies.defmt]
Expand Down
3 changes: 2 additions & 1 deletion src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use core::str::FromStr;
use core::{fmt, str};

use serde::de::{self, Visitor};
use serde::Serialize;

use self::enum_::{UnitVariantAccess, VariantAccess};
use self::map::MapAccess;
Expand All @@ -17,7 +18,7 @@ mod seq;
pub type Result<T> = core::result::Result<T, Error>;

/// This type represents all possible errors that can occur when deserializing JSON data
#[derive(Debug, PartialEq, Eq, Clone)]
#[derive(Debug, PartialEq, Eq, Clone, Serialize)]
#[cfg_attr(not(feature = "custom-error-messages"), derive(Copy))]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[non_exhaustive]
Expand Down
3 changes: 2 additions & 1 deletion src/ser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use core::mem::MaybeUninit;
use core::{fmt, str};

use serde::ser;
use serde::Serialize;
use serde::ser::SerializeStruct as _;

#[cfg(feature = "heapless")]
Expand All @@ -21,7 +22,7 @@ mod struct_;
pub type Result<T> = ::core::result::Result<T, Error>;

/// This type represents all possible errors that can occur when serializing JSON data
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
#[derive(Debug, PartialEq, Eq, Copy, Clone, Serialize)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[non_exhaustive]
pub enum Error {
Expand Down

0 comments on commit a0dad18

Please sign in to comment.