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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
pub(crate) const ABOUT: &str = concat!(
env!("CARGO_PKG_DESCRIPTION"),
" - ",
env!("CARGO_PKG_HOMEPAGE")
);
pub(crate) const AUTHOR: &str = env!("CARGO_PKG_AUTHORS");
/// Default value for `created by` torrent metainfo field.
///
/// Example: imdl/0.0.0 (1234567890ab)
pub(crate) const CREATED_BY_DEFAULT: &str = concat!(
"imdl/",
env!("CARGO_PKG_VERSION"),
env!("GIT_HEAD_PARTIAL_HASH"),
);
/// Value for `encoding` torrent metainfo field.
pub(crate) const ENCODING_UTF8: &str = "UTF-8";
pub(crate) const HELP_MESSAGE: &str = "Print help message.";
/// The progress chars are from the
/// [Block Elements unicode block](https://en.wikipedia.org/wiki/Block_Elements).
pub(crate) const PROGRESS_CHARS: &str = "█▉▊▋▌▍▎▏ ";
/// The tick chars are from the
/// [Braille Patterns unicode block](https://en.wikipedia.org/wiki/Braille_Patterns).
///
/// The chars are ordered to represent the 8 bit numbers in increasing
/// order. The individual braille cells represent bits, with empty cells
/// representing `0` and full cells representing `1`.
///
/// Digits are ordered from least significant to most significant from
/// top to bottom, and then left to right, like so:
///
/// ```text
/// ╔═════╗
/// ║ 0 4 ║
/// ║ 1 5 ║
/// ║ 2 6 ║
/// ║ 3 7 ║
/// ╚═════╝
/// ```
pub(crate) const TICK_CHARS: &str = concat!(
"⠀⠁⠂⠃⠄⠅⠆⠇⡀⡁⡂⡃⡄⡅⡆⡇", // 0b0000----
"⠈⠉⠊⠋⠌⠍⠎⠏⡈⡉⡊⡋⡌⡍⡎⡏", // 0b0001----
"⠐⠑⠒⠓⠔⠕⠖⠗⡐⡑⡒⡓⡔⡕⡖⡗", // 0b0010----
"⠘⠙⠚⠛⠜⠝⠞⠟⡘⡙⡚⡛⡜⡝⡞⡟", // 0b0011----
"⠠⠡⠢⠣⠤⠥⠦⠧⡠⡡⡢⡣⡤⡥⡦⡧", // 0b0100----
"⠨⠩⠪⠫⠬⠭⠮⠯⡨⡩⡪⡫⡬⡭⡮⡯", // 0b0101----
"⠰⠱⠲⠳⠴⠵⠶⠷⡰⡱⡲⡳⡴⡵⡶⡷", // 0b0110----
"⠸⠹⠺⠻⠼⠽⠾⠿⡸⡹⡺⡻⡼⡽⡾⡿", // 0b0111----
"⢀⢁⢂⢃⢄⢅⢆⢇⣀⣁⣂⣃⣄⣅⣆⣇", // 0b1000----
"⢈⢉⢊⢋⢌⢍⢎⢏⣈⣉⣊⣋⣌⣍⣎⣏", // 0b1001----
"⢐⢑⢒⢓⢔⢕⢖⢗⣐⣑⣒⣓⣔⣕⣖⣗", // 0b1010----
"⢘⢙⢚⢛⢜⢝⢞⢟⣘⣙⣚⣛⣜⣝⣞⣟", // 0b1011----
"⢠⢡⢢⢣⢤⢥⢦⢧⣠⣡⣢⣣⣤⣥⣦⣧", // 0b1100----
"⢨⢩⢪⢫⢬⢭⢮⢯⣨⣩⣪⣫⣬⣭⣮⣯", // 0b1101----
"⢰⢱⢲⢳⢴⢵⢶⢷⣰⣱⣲⣳⣴⣵⣶⣷", // 0b1110----
"⢸⢹⢺⢻⢼⢽⢾⢿⣸⣹⣺⣻⣼⣽⣾⣿", // 0b1111----
);
pub(crate) const PROGRESS_STYLE: &str = "{spinner:.green} ⟪{elapsed_precise}⟫ ⟦{wide_bar:.cyan}⟧ \
{binary_bytes}/{binary_total_bytes} \
⟨{binary_bytes_per_sec}, {eta}⟩";
pub(crate) const VERSION: &str = concat!("v", env!("CARGO_PKG_VERSION"));
pub(crate) const VERSION_MESSAGE: &str = "Print version number.";
#[cfg(test)]
mod tests {
use super::*;
use crate::common::*;
#[test]
fn created_by() {
let pattern = Regex::new(
r"(?x)
imdl/
[0-9]+.[0-9]+.[0-9]+(-.*)?
(
[\ ]
\(
[0-9a-f]{12}
\)
)?
",
)
.unwrap();
assert!(
pattern.is_match(CREATED_BY_DEFAULT),
"Bad created by string: `{CREATED_BY_DEFAULT}`",
);
}
}