aria2_rs/
options.rs

1// Copied from aria2-ws-rs(https://github.com/WOo0W/aria2-ws-rs)
2// All rights reserved by the original author.
3
4use serde::{Deserialize, Serialize};
5use serde_json::Value;
6use serde_with::{serde_as, skip_serializing_none, DisplayFromStr};
7use smol_str::SmolStr;
8
9use crate::{SmallMap, SmallVec};
10
11#[serde_as]
12#[skip_serializing_none]
13#[derive(Serialize, Deserialize, Clone, Default)]
14#[serde(rename_all = "kebab-case")]
15pub struct TaskOptions {
16    pub header: Option<SmallVec<SmolStr>>,
17
18    #[serde_as(as = "Option<DisplayFromStr>")]
19    pub split: Option<i32>,
20
21    pub all_proxy: Option<SmolStr>,
22
23    pub dir: Option<SmolStr>,
24
25    pub out: Option<SmolStr>,
26
27    pub gid: Option<SmolStr>,
28
29    #[serde_as(as = "Option<DisplayFromStr>")]
30    pub r#continue: Option<bool>,
31
32    #[serde_as(as = "Option<DisplayFromStr>")]
33    pub auto_file_renaming: Option<bool>,
34
35    #[serde_as(as = "Option<DisplayFromStr>")]
36    pub check_integrity: Option<bool>,
37
38    /// Close connection if download speed is lower than or equal to this value(bytes per sec).
39    ///
40    /// 0 means aria2 does not have a lowest speed limit.
41    ///
42    /// You can append K or M (1K = 1024, 1M = 1024K).
43    ///
44    /// This option does not affect BitTorrent downloads.
45    ///
46    /// Default: 0
47    pub lowest_speed_limit: Option<SmolStr>,
48
49    /// Set max download speed per each download in bytes/sec. 0 means unrestricted.
50    ///
51    /// You can append K or M (1K = 1024, 1M = 1024K).
52    ///
53    /// To limit the overall download speed, use --max-overall-download-limit option.
54    ///
55    /// Default: 0
56    pub max_download_limit: Option<SmolStr>,
57
58    #[serde_as(as = "Option<DisplayFromStr>")]
59    pub max_connection_per_server: Option<i32>,
60
61    #[serde_as(as = "Option<DisplayFromStr>")]
62    pub max_tries: Option<i32>,
63
64    #[serde_as(as = "Option<DisplayFromStr>")]
65    pub timeout: Option<i32>,
66
67    #[serde(flatten)]
68    pub extra_options: SmallMap<SmolStr, Value>,
69}