mirror of
https://github.com/kristoferssolo/transmission-rpc.git
synced 2025-10-21 20:10:37 +00:00
feat: helper
This commit is contained in:
parent
f61a41be8a
commit
ed924a5a51
@ -1,6 +1,8 @@
|
||||
use serde::Deserialize;
|
||||
use serde_repr::*;
|
||||
|
||||
use crate::types::Id;
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct RpcResponse<T: RpcResponseArgument> {
|
||||
pub arguments: T,
|
||||
@ -123,6 +125,16 @@ pub struct Torrent {
|
||||
pub file_stats: Option<Vec<FileStat>>,
|
||||
}
|
||||
|
||||
impl Torrent {
|
||||
/// Get either the ID or the hash string if exist, which are both unique and
|
||||
/// can be pass to the API.
|
||||
pub fn id(&self) -> Option<Id> {
|
||||
self.id
|
||||
.map(Id::Id)
|
||||
.or_else(|| self.hash_string.clone().map(Id::Hash))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Stats {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user