Use serde's rename_all everywhere

This commit is contained in:
Artem Vorotnikov 2022-10-15 03:06:25 +04:00 committed by Aleksandr
parent cf720e36cd
commit 405bc6dba6

View File

@ -13,31 +13,24 @@ impl<T: RpcResponseArgument> RpcResponse<T> {
pub trait RpcResponseArgument {}
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "kebab-case")]
pub struct SessionGet {
#[serde(rename = "blocklist-enabled")]
pub blocklist_enabled: bool,
#[serde(rename = "download-dir")]
pub download_dir: String,
pub encryption: String,
#[serde(rename = "rpc-version")]
pub rpc_version: i32,
#[serde(rename = "rpc-version-minimum")]
pub rpc_version_minimum: i32,
pub version: String,
}
impl RpcResponseArgument for SessionGet {}
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct SessionStats {
#[serde(rename = "torrentCount")]
pub torrent_count: i32,
#[serde(rename = "activeTorrentCount")]
pub active_torrent_count: i32,
#[serde(rename = "pausedTorrentCount")]
pub paused_torrent_count: i32,
#[serde(rename = "downloadSpeed")]
pub download_speed: i64,
#[serde(rename = "uploadSpeed")]
pub upload_speed: i64,
#[serde(rename = "current-stats")]
pub current_stats: Stats,
@ -51,109 +44,78 @@ pub struct SessionClose {}
impl RpcResponseArgument for SessionClose {}
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "kebab-case")]
pub struct BlocklistUpdate {
#[serde(rename = "blocklist-size")]
pub blocklist_size: Option<i32>,
}
impl RpcResponseArgument for BlocklistUpdate {}
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "kebab-case")]
pub struct FreeSpace {
pub path: String,
#[serde(rename = "size-bytes")]
pub size_bytes: i64,
}
impl RpcResponseArgument for FreeSpace {}
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "kebab-case")]
pub struct PortTest {
#[serde(rename = "port-is-open")]
pub port_is_open: bool,
}
impl RpcResponseArgument for PortTest {}
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Torrent {
#[serde(rename = "activityDate")]
pub activity_date: Option<i64>,
#[serde(rename = "addedDate")]
pub added_date: Option<i64>,
#[serde(rename = "doneDate")]
pub done_date: Option<i64>,
#[serde(rename = "downloadDir")]
pub download_dir: Option<String>,
#[serde(rename = "editDate")]
pub edit_date: Option<i64>,
pub error: Option<i64>,
#[serde(rename = "errorString")]
pub error_string: Option<String>,
pub eta: Option<i64>,
pub id: Option<i64>,
#[serde(rename = "isFinished")]
pub is_finished: Option<bool>,
#[serde(rename = "isPrivate")]
pub is_private: Option<bool>,
#[serde(rename = "isStalled")]
pub is_stalled: Option<bool>,
#[serde(rename = "labels")]
pub labels: Option<Vec<String>>,
#[serde(rename = "leftUntilDone")]
pub left_until_done: Option<i64>,
#[serde(rename = "metadataPercentComplete")]
pub metadata_percent_complete: Option<f32>,
pub name: Option<String>,
#[serde(rename = "hashString")]
pub hash_string: Option<String>,
#[serde(rename = "peersConnected")]
pub peers_connected: Option<i64>,
#[serde(rename = "peersGettingFromUs")]
pub peers_getting_from_us: Option<i64>,
#[serde(rename = "peersSendingToUs")]
pub peers_sending_to_us: Option<i64>,
#[serde(rename = "percentDone")]
pub percent_done: Option<f32>,
#[serde(rename = "rateDownload")]
pub rate_download: Option<i64>,
#[serde(rename = "rateUpload")]
pub rate_upload: Option<i64>,
#[serde(rename = "recheckProgress")]
pub recheck_progress: Option<f32>,
#[serde(rename = "secondsSeeding")]
pub seconds_seeding: Option<i64>,
#[serde(rename = "seedRatioLimit")]
pub seed_ratio_limit: Option<f32>,
#[serde(rename = "sizeWhenDone")]
pub size_when_done: Option<i64>,
pub status: Option<i64>,
#[serde(rename = "torrentFile")]
pub torrent_file: Option<String>,
#[serde(rename = "totalSize")]
pub total_size: Option<i64>,
pub trackers: Option<Vec<Trackers>>,
#[serde(rename = "uploadRatio")]
pub upload_ratio: Option<f32>,
#[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, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Stats {
#[serde(rename = "filesAdded")]
pub files_added: i32,
#[serde(rename = "downloadedBytes")]
pub downloaded_bytes: i64,
#[serde(rename = "uploadedBytes")]
pub uploaded_bytes: i64,
#[serde(rename = "secondsActive")]
pub seconds_active: i64,
#[serde(rename = "sessionCount")]
pub session_count: Option<i32>,
}
@ -170,16 +132,16 @@ pub struct Trackers {
}
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct File {
pub length: i64,
#[serde(rename = "bytesCompleted")]
pub bytes_completed: i64,
pub name: String,
}
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct FileStat {
#[serde(rename = "bytesCompleted")]
pub bytes_completed: i64,
pub wanted: bool,
/// low: -1, normal: 0, high: 1