mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 10:15:31 +00:00
Move all crates to new crates dir
This commit is contained in:
parent
3835da22ac
commit
9b032f7e24
128 changed files with 27 additions and 26 deletions
29
crates/ws_protocol/src/request/scrape.rs
Normal file
29
crates/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