mirror of
https://github.com/kristoferssolo/transmission-rpc.git
synced 2025-10-21 20:10:37 +00:00
handle files wanted/unwanted/priorities for torrent-add & torrent-get
This commit is contained in:
parent
cf1bdb95d2
commit
21f0b62bac
@ -10,7 +10,6 @@ pub struct BasicAuth {
|
||||
}
|
||||
|
||||
pub use self::request::ArgumentFields;
|
||||
pub use self::request::File;
|
||||
pub use self::request::Id;
|
||||
pub(crate) use self::request::RpcRequest;
|
||||
pub use self::request::TorrentAction;
|
||||
|
||||
@ -146,16 +146,22 @@ pub struct TorrentAddArgs {
|
||||
pub peer_limit: Option<i64>,
|
||||
#[serde(skip_serializing_if = "Option::is_none", rename = "bandwidthPriority")]
|
||||
pub bandwidth_priority: Option<i64>,
|
||||
/// list of indices of files to be downloaded
|
||||
/// to ignore some files, put their indices in files_unwanted, otherwise they will still be downloaded
|
||||
#[serde(skip_serializing_if = "Option::is_none", rename = "files-wanted")]
|
||||
pub files_wanted: Option<Vec<File>>,
|
||||
pub files_wanted: Option<Vec<i32>>,
|
||||
/// list of indices of files not to download
|
||||
#[serde(skip_serializing_if = "Option::is_none", rename = "files-unwanted")]
|
||||
pub files_unwanted: Option<Vec<File>>,
|
||||
pub files_unwanted: Option<Vec<i32>>,
|
||||
/// list of indices of files to be downloaded with high priority
|
||||
#[serde(skip_serializing_if = "Option::is_none", rename = "priority-high")]
|
||||
pub priority_high: Option<Vec<File>>,
|
||||
pub priority_high: Option<Vec<i32>>,
|
||||
/// list of indices of files to be downloaded with low priority
|
||||
#[serde(skip_serializing_if = "Option::is_none", rename = "priority-low")]
|
||||
pub priority_low: Option<Vec<File>>,
|
||||
pub priority_low: Option<Vec<i32>>,
|
||||
/// list of indices of files to be downloaded with normal priority
|
||||
#[serde(skip_serializing_if = "Option::is_none", rename = "priority-normal")]
|
||||
pub priority_normal: Option<Vec<File>>,
|
||||
pub priority_normal: Option<Vec<i32>>,
|
||||
}
|
||||
|
||||
impl Default for TorrentAddArgs {
|
||||
@ -177,10 +183,6 @@ impl Default for TorrentAddArgs {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug, RustcEncodable, Clone)]
|
||||
pub struct File {
|
||||
//todo
|
||||
}
|
||||
#[derive(Clone, IntoEnumIterator)]
|
||||
pub enum TorrentGetField {
|
||||
Id,
|
||||
@ -213,6 +215,9 @@ pub enum TorrentGetField {
|
||||
Uploadedever,
|
||||
Uploadratio,
|
||||
Webseedssendingtous,
|
||||
Wanted,
|
||||
Priorities,
|
||||
Filestats
|
||||
}
|
||||
|
||||
impl TorrentGetField {
|
||||
@ -254,6 +259,9 @@ impl TorrentGetField {
|
||||
TorrentGetField::Uploadedever => "uploadedEver",
|
||||
TorrentGetField::Uploadratio => "uploadRatio",
|
||||
TorrentGetField::Webseedssendingtous => "webseedsSendingToUs",
|
||||
TorrentGetField::Wanted => "wanted",
|
||||
TorrentGetField::Priorities => "priorities",
|
||||
TorrentGetField::Filestats => "fileStats",
|
||||
}.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,6 +76,12 @@ pub struct Torrent {
|
||||
#[serde(rename = "uploadedEver")]
|
||||
pub uploaded_ever: Option<i64>,
|
||||
pub files: Option<Vec<File>>,
|
||||
/// for each file in files, whether or not they will be downloaded (0 or 1)
|
||||
pub wanted: Option<Vec<i8>>,
|
||||
/// for each file in files, their download priority (low:-1,normal:0,high:1)
|
||||
pub priorities: Option<Vec<i8>>,
|
||||
#[serde(rename = "fileStats")]
|
||||
pub file_stats: Option<Vec<FileStat>>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, RustcEncodable)]
|
||||
@ -98,6 +104,15 @@ pub struct File {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, RustcEncodable, Clone)]
|
||||
pub struct FileStat {
|
||||
#[serde(rename = "bytesCompleted")]
|
||||
pub bytes_completed: i64,
|
||||
pub wanted: bool,
|
||||
/// low: -1, normal: 0, high: 1
|
||||
pub priority: i8,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, RustcEncodable)]
|
||||
pub struct Nothing {}
|
||||
impl RpcResponseArgument for Nothing {}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user