Remove dead code

This commit is contained in:
Franck Royer 2020-12-22 13:50:36 +11:00
parent df237f82cf
commit 40a27a2438
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
2 changed files with 0 additions and 48 deletions

View File

@ -9,7 +9,6 @@ pub mod bob;
pub mod cli; pub mod cli;
pub mod monero; pub mod monero;
pub mod network; pub mod network;
pub mod serde;
pub mod state; pub mod state;
pub mod storage; pub mod storage;
pub mod trace; pub mod trace;

View File

@ -1,47 +0,0 @@
pub mod peer_id {
use libp2p::PeerId;
use serde::{de::Error, Deserialize, Deserializer, Serializer};
pub fn serialize<S>(peer_id: &PeerId, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let string = peer_id.to_string();
serializer.serialize_str(&string)
}
#[allow(dead_code)]
pub fn deserialize<'de, D>(deserializer: D) -> Result<PeerId, D::Error>
where
D: Deserializer<'de>,
{
let string = String::deserialize(deserializer)?;
let peer_id = string.parse().map_err(D::Error::custom)?;
Ok(peer_id)
}
#[cfg(test)]
mod tests {
use super::*;
use serde::Serialize;
use spectral::prelude::*;
#[derive(Serialize)]
struct SerializablePeerId(#[serde(with = "super")] PeerId);
#[test]
fn maker_id_serializes_as_expected() {
let peer_id = SerializablePeerId(
"QmfUfpC2frwFvcDzpspnfZitHt5wct6n4kpG5jzgRdsxkY"
.parse()
.unwrap(),
);
let got = serde_json::to_string(&peer_id).expect("failed to serialize peer id");
assert_that(&got)
.is_equal_to(r#""QmfUfpC2frwFvcDzpspnfZitHt5wct6n4kpG5jzgRdsxkY""#.to_string());
}
}
}