aria2_ws/
options.rs

1use serde::{Deserialize, Serialize};
2use serde_json::{Map, Value};
3use serde_with::{serde_as, skip_serializing_none, DisplayFromStr};
4
5/// Regular options of aria2 download tasks.
6///
7/// For more options, add them to `extra_options` field, which is Object in `serde_json`.
8///
9/// You can find all options in <https://aria2.github.io/manual/en/html/aria2c.html#input-file>
10#[serde_as]
11#[skip_serializing_none]
12#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
13#[serde(rename_all = "kebab-case")]
14pub struct TaskOptions {
15    pub header: Option<Vec<String>>,
16
17    #[serde_as(as = "Option<DisplayFromStr>")]
18    pub split: Option<i32>,
19
20    pub all_proxy: Option<String>,
21
22    pub dir: Option<String>,
23
24    pub out: Option<String>,
25
26    pub gid: Option<String>,
27
28    #[serde_as(as = "Option<DisplayFromStr>")]
29    pub r#continue: Option<bool>,
30
31    #[serde_as(as = "Option<DisplayFromStr>")]
32    pub auto_file_renaming: Option<bool>,
33
34    #[serde_as(as = "Option<DisplayFromStr>")]
35    pub check_integrity: Option<bool>,
36
37    /// Close connection if download speed is lower than or equal to this value(bytes per sec).
38    ///
39    /// 0 means aria2 does not have a lowest speed limit.
40    ///
41    /// You can append K or M (1K = 1024, 1M = 1024K).
42    ///
43    /// This option does not affect BitTorrent downloads.
44    ///
45    /// Default: 0
46    pub lowest_speed_limit: Option<String>,
47
48    /// Set max download speed per each download in bytes/sec. 0 means unrestricted.
49    ///
50    /// You can append K or M (1K = 1024, 1M = 1024K).
51    ///
52    /// To limit the overall download speed, use --max-overall-download-limit option.
53    ///
54    /// Default: 0
55    pub max_download_limit: Option<String>,
56
57    #[serde_as(as = "Option<DisplayFromStr>")]
58    pub max_connection_per_server: Option<i32>,
59
60    #[serde_as(as = "Option<DisplayFromStr>")]
61    pub max_tries: Option<i32>,
62
63    #[serde_as(as = "Option<DisplayFromStr>")]
64    pub timeout: Option<i32>,
65
66    #[serde(flatten)]
67    pub extra_options: Map<String, Value>,
68}