http_protocol: add AnnounceEvent::as_str, run cargo fmt

This commit is contained in:
Joakim Frostegård 2022-04-02 13:31:51 +02:00
parent b9c029b5ed
commit 87223f7952
2 changed files with 18 additions and 3 deletions

View file

@ -52,6 +52,17 @@ impl FromStr for AnnounceEvent {
}
}
impl AnnounceEvent {
pub fn as_str(&self) -> Option<&str> {
match self {
Self::Started => Some("started"),
Self::Stopped => Some("stopped"),
Self::Completed => Some("completed"),
Self::Empty => None,
}
}
}
#[cfg(test)]
impl quickcheck::Arbitrary for InfoHash {
fn arbitrary(g: &mut quickcheck::Gen) -> Self {