mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 09:45:31 +00:00
http_protocol: add AnnounceEvent::as_str, run cargo fmt
This commit is contained in:
parent
b9c029b5ed
commit
87223f7952
2 changed files with 18 additions and 3 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -283,9 +283,13 @@ impl Request {
|
|||
let query_string = split_parts.next().with_context(|| "no query string")?;
|
||||
|
||||
if location == "/announce" {
|
||||
Ok(Request::Announce(AnnounceRequest::from_query_string(query_string)?))
|
||||
Ok(Request::Announce(AnnounceRequest::from_query_string(
|
||||
query_string,
|
||||
)?))
|
||||
} else {
|
||||
Ok(Request::Scrape(ScrapeRequest::from_query_string(query_string)?))
|
||||
Ok(Request::Scrape(ScrapeRequest::from_query_string(
|
||||
query_string,
|
||||
)?))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue