aquatic_http: add hand-written ScrapeResponse serialization

This commit is contained in:
Joakim Frostegård 2020-07-18 17:46:16 +02:00
parent 17385c92ad
commit 84facea0ca
4 changed files with 94 additions and 26 deletions

View file

@ -15,7 +15,7 @@ pub struct PeerId(
);
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize)]
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize)]
#[serde(transparent)]
pub struct InfoHash(
#[serde(
@ -53,4 +53,19 @@ impl FromStr for AnnounceEvent {
value => Err(format!("Unknown value: {}", value))
}
}
}
#[cfg(test)]
impl quickcheck::Arbitrary for InfoHash {
fn arbitrary<G: quickcheck::Gen>(g: &mut G) -> Self {
let mut arr = [b'x'; 20];
arr[0] = u8::arbitrary(g);
arr[1] = u8::arbitrary(g);
arr[18] = u8::arbitrary(g);
arr[19] = u8::arbitrary(g);
Self(arr)
}
}