Skip to content

Commit

Permalink
Add serdey.rs from Fiono11-simplpedpop
Browse files Browse the repository at this point in the history
  • Loading branch information
burdges committed May 1, 2024
1 parent 8894a37 commit 3bfad6d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/serdey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
#[cfg(feature = "serde")]
#[rustfmt::skip]
macro_rules! serde_boilerplate { ($t:ty) => {
impl serde_crate::Serialize for $t {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde_crate::Serializer {
impl serde::Serialize for $t {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {
let bytes = &self.to_bytes()[..];
serde_bytes::Bytes::new(bytes).serialize(serializer)
}
}

impl<'d> serde_crate::Deserialize<'d> for $t {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde_crate::Deserializer<'d> {
impl<'d> serde::Deserialize<'d> for $t {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: serde::Deserializer<'d> {
cfg_if::cfg_if!{
if #[cfg(feature = "std")] {
let bytes = <std::borrow::Cow<'_, [u8]>>::deserialize(deserializer)?;
Expand Down

0 comments on commit 3bfad6d

Please sign in to comment.