aquatic_http: clean up / move around code; update TODO

This commit is contained in:
Joakim Frostegård 2020-07-02 15:34:56 +02:00
parent c8de9857f8
commit 6fc4b693cd
4 changed files with 29 additions and 33 deletions

View file

@ -9,30 +9,6 @@ mod serde_helpers;
use serde_helpers::*;
pub fn serialize_response_peers_compact<S>(
response_peers: &Vec<ResponsePeer>,
serializer: S
) -> Result<S::Ok, S::Error> where S: Serializer {
let mut bytes = Vec::with_capacity(response_peers.len() * 6);
for peer in response_peers {
match peer.ip_address {
IpAddr::V4(ip) => {
bytes.extend_from_slice(&u32::from(ip).to_be_bytes());
bytes.extend_from_slice(&peer.port.to_be_bytes())
},
IpAddr::V6(_) => {
continue
}
}
}
let text: String = bytes.into_iter().map(|byte| byte as char).collect();
serializer.serialize_str(&text)
}
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
#[serde(transparent)]
pub struct PeerId(