-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTorrentOption.swift
57 lines (52 loc) · 1.73 KB
/
TorrentOption.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/// An option that can be set on a torrent.
public struct TorrentOption {
/// The key identifying the option.
///
/// Refer to the
/// [RPC spec](https://git.deluge-torrent.org/deluge/tree/deluge/core/torrent.py) for valid keys.
public var key: String
/// The value of the option.
public var value: Any
}
public extension TorrentOption {
/// Marks the files with the given indices as wanted.
///
/// Key: `files-wanted`
///
/// - Parameter indices: The file indices to update.
static func filesWanted(indices: [Int]) -> Self {
.init(key: "files-wanted", value: indices)
}
/// Marks the files with the given indices as unwanted.
///
/// Key: `files-unwanted`
///
/// - Parameter indices: The file indices to update.
static func filesUnwanted(indices: [Int]) -> Self {
.init(key: "files-unwanted", value: indices)
}
/// Sets the priority to low for files with the given indices.
///
/// Key: `priority-low`
///
/// - Parameter indices: The file indices to update.
static func priorityLow(indices: [Int]) -> Self {
.init(key: "priority-low", value: indices)
}
/// Sets the priority to normal for files with the given indices.
///
/// Key: `priority-normal`
///
/// - Parameter indices: The file indices to update.
static func priorityNormal(indices: [Int]) -> Self {
.init(key: "priority-normal", value: indices)
}
/// Sets the priority to high for files with the given indices.
///
/// Key: `priority-high`
///
/// - Parameter indices: The file indices to update.
static func priorityHigh(indices: [Int]) -> Self {
.init(key: "priority-high", value: indices)
}
}