mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 18:25:30 +00:00
aquatic_ws_protocol: refactor, moving code into submodules
This commit is contained in:
parent
7c833958d8
commit
71c43aca47
11 changed files with 345 additions and 304 deletions
29
aquatic_ws_protocol/src/request/scrape.rs
Normal file
29
aquatic_ws_protocol/src/request/scrape.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::common::*;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum ScrapeRequestInfoHashes {
|
||||
Single(InfoHash),
|
||||
Multiple(Vec<InfoHash>),
|
||||
}
|
||||
|
||||
impl ScrapeRequestInfoHashes {
|
||||
pub fn as_vec(self) -> Vec<InfoHash> {
|
||||
match self {
|
||||
Self::Single(info_hash) => vec![info_hash],
|
||||
Self::Multiple(info_hashes) => info_hashes,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ScrapeRequest {
|
||||
pub action: ScrapeAction,
|
||||
// If omitted, scrape for all torrents, apparently
|
||||
// There is some kind of parsing here too which accepts a single info hash
|
||||
// and puts it into a vector
|
||||
#[serde(rename = "info_hash")]
|
||||
pub info_hashes: Option<ScrapeRequestInfoHashes>,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue