-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore serialization of Block and Evidence
Define hand-written Serialize/Deserialize impls for Evidence.
- Loading branch information
Showing
7 changed files
with
62 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
mod v0_34 { | ||
use crate::v0_34::types::{evidence, Evidence}; | ||
use serde::{Deserialize, Deserializer, Serialize, Serializer}; | ||
|
||
impl<'de> Deserialize<'de> for Evidence { | ||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
{ | ||
let sum = Option::<evidence::Sum>::deserialize(deserializer)?; | ||
Ok(Self { sum }) | ||
} | ||
} | ||
|
||
impl Serialize for Evidence { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: Serializer, | ||
{ | ||
self.sum.serialize(serializer) | ||
} | ||
} | ||
} | ||
|
||
mod v0_37 { | ||
use crate::v0_37::types::{evidence, Evidence}; | ||
use serde::{Deserialize, Deserializer, Serialize, Serializer}; | ||
|
||
impl<'de> Deserialize<'de> for Evidence { | ||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
{ | ||
let sum = Option::<evidence::Sum>::deserialize(deserializer)?; | ||
Ok(Self { sum }) | ||
} | ||
} | ||
|
||
impl Serialize for Evidence { | ||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: Serializer, | ||
{ | ||
self.sum.serialize(serializer) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters