Debian Codegraph @

src/options/mod.rs

raw symbols SCIP
1 //! Describes the struct that holds the options needed by the formatting functions.
2 //! The three most common formats are provided as constants to be used easily
3
4 mod defaultsrust-analyzer cargo humansize 2.1.3 options/defaults/;
5 pub use selfrust-analyzer cargo humansize 2.1.3 options/::defaultsrust-analyzer cargo humansize 2.1.3 options/defaults/::*;
6
7 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
8 /// Holds the standard to use when displaying the size.
9 pub enum Kilorust-analyzer cargo humansize 2.1.3 options/Kilo# {
10 /// The decimal scale and units. SI standard.
11 Decimalrust-analyzer cargo humansize 2.1.3 options/Kilo#Decimal#,
12 /// The binary scale and units.
13 Binaryrust-analyzer cargo humansize 2.1.3 options/Kilo#Binary#,
14 }
15
16 impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Kilorust-analyzer cargo humansize 2.1.3 options/Kilo# {
17 fn defaultrust-analyzer cargo humansize 2.1.3 options/impl#[Kilo][Default]default().() -> Selfrust-analyzer cargo humansize 2.1.3 options/impl#[Kilo][Default] {
18 Selfrust-analyzer cargo humansize 2.1.3 options/impl#[Kilo][Default]::Decimalrust-analyzer cargo humansize 2.1.3 options/Kilo#Decimal#
19 }
20 }
21
22 impl Kilorust-analyzer cargo humansize 2.1.3 options/Kilo# {
23 pub(craterust-analyzer cargo humansize 2.1.3 crate/) fn valuerust-analyzer cargo humansize 2.1.3 options/impl#[Kilo]value().(&self) -> f64 {
24 match self {
25 Kilorust-analyzer cargo humansize 2.1.3 options/Kilo#::Decimalrust-analyzer cargo humansize 2.1.3 options/Kilo#Decimal# => 1000.0,
26 Kilorust-analyzer cargo humansize 2.1.3 options/Kilo#::Binaryrust-analyzer cargo humansize 2.1.3 options/Kilo#Binary# => 1024.0,
27 }
28 }
29 }
30
31 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
32 /// Forces a certain representation of the resulting file size.
33 pub enum FixedAtrust-analyzer cargo humansize 2.1.3 options/FixedAt# {
34 Baserust-analyzer cargo humansize 2.1.3 options/FixedAt#Base#,
35 Kilorust-analyzer cargo humansize 2.1.3 options/FixedAt#Kilo#,
36 Megarust-analyzer cargo humansize 2.1.3 options/FixedAt#Mega#,
37 Gigarust-analyzer cargo humansize 2.1.3 options/FixedAt#Giga#,
38 Terarust-analyzer cargo humansize 2.1.3 options/FixedAt#Tera#,
39 Petarust-analyzer cargo humansize 2.1.3 options/FixedAt#Peta#,
40 Exarust-analyzer cargo humansize 2.1.3 options/FixedAt#Exa#,
41 Zettarust-analyzer cargo humansize 2.1.3 options/FixedAt#Zetta#,
42 Yottarust-analyzer cargo humansize 2.1.3 options/FixedAt#Yotta#,
43 }
44
45 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
46 pub enum BaseUnitrust-analyzer cargo humansize 2.1.3 options/BaseUnit# {
47 Bitrust-analyzer cargo humansize 2.1.3 options/BaseUnit#Bit#,
48 Byterust-analyzer cargo humansize 2.1.3 options/BaseUnit#Byte#,
49 }
50
51 impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for BaseUnitrust-analyzer cargo humansize 2.1.3 options/BaseUnit# {
52 fn defaultrust-analyzer cargo humansize 2.1.3 options/impl#[BaseUnit][Default]default().() -> Selfrust-analyzer cargo humansize 2.1.3 options/impl#[BaseUnit][Default] {
53 Selfrust-analyzer cargo humansize 2.1.3 options/impl#[BaseUnit][Default]::Byterust-analyzer cargo humansize 2.1.3 options/BaseUnit#Byte#
54 }
55 }
56
57 /// Holds the options for the `file_size` method.
58 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)]
59 #[non_exhaustive]
60 pub struct FormatSizeOptionsBuilderrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptionsBuilder# {
61 /// Whether the value being formatted represents an amount of bits or bytes.
62 pub base_unitrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptionsBuilder#base_unit.: BaseUnitrust-analyzer cargo humansize 2.1.3 options/BaseUnit#,
63
64 /// The scale (binary/decimal) to divide against.
65 pub kilorust-analyzer cargo humansize 2.1.3 options/FormatSizeOptionsBuilder#kilo.: Kilorust-analyzer cargo humansize 2.1.3 options/Kilo#,
66
67 /// The unit set to display.
68 pub unitsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptionsBuilder#units.: Kilorust-analyzer cargo humansize 2.1.3 options/Kilo#,
69
70 /// The amount of decimal places to display if the decimal part is non-zero.
71 pub decimal_placesrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptionsBuilder#decimal_places.: usize,
72
73 /// The amount of zeroes to display if the decimal part is zero.
74 pub decimal_zeroesrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptionsBuilder#decimal_zeroes.: usize,
75
76 /// Whether to force a certain representation and if so, which one.
77 pub fixed_atrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptionsBuilder#fixed_at.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<FixedAtrust-analyzer cargo humansize 2.1.3 options/FixedAt#>,
78
79 /// Whether to use the full unit (e.g. `Kilobyte`) or its abbreviation (`kB`).
80 pub long_unitsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptionsBuilder#long_units.: bool,
81
82 /// Whether to place a space between value and units.
83 pub space_after_valuerust-analyzer cargo humansize 2.1.3 options/FormatSizeOptionsBuilder#space_after_value.: bool,
84
85 /// An optional suffix which will be appended after the unit. Useful to represent speeds (e.g. `1 kB/s)
86 pub suffixrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptionsBuilder#suffix.: &'static str,
87 }
88
89 /// Holds the options for the `file_size` method.
90 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)]
91 #[non_exhaustive]
92 pub struct FormatSizeOptionsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions# {
93 /// Whether the value being formatted represents an amount of bits or bytes.
94 pub base_unitrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions#base_unit.: BaseUnitrust-analyzer cargo humansize 2.1.3 options/BaseUnit#,
95
96 /// The scale (binary/decimal) to divide against.
97 pub kilorust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions#kilo.: Kilorust-analyzer cargo humansize 2.1.3 options/Kilo#,
98
99 /// The unit set to display.
100 pub unitsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions#units.: Kilorust-analyzer cargo humansize 2.1.3 options/Kilo#,
101
102 /// The amount of decimal places to display if the decimal part is non-zero.
103 pub decimal_placesrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions#decimal_places.: usize,
104
105 /// The amount of zeroes to display if the decimal part is zero.
106 pub decimal_zeroesrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions#decimal_zeroes.: usize,
107
108 /// Whether to force a certain representation and if so, which one.
109 pub fixed_atrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions#fixed_at.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<FixedAtrust-analyzer cargo humansize 2.1.3 options/FixedAt#>,
110
111 /// Whether to use the full unit (e.g. `Kilobyte`) or its abbreviation (`kB`).
112 pub long_unitsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions#long_units.: bool,
113
114 /// Whether to place a space between value and units.
115 pub space_after_valuerust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions#space_after_value.: bool,
116
117 /// An optional suffix which will be appended after the unit. Useful to represent speeds (e.g. `1 kB/s)
118 pub suffixrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions#suffix.: &'static str,
119 }
120
121 impl FormatSizeOptionsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions# {
122 pub fn fromrust-analyzer cargo humansize 2.1.3 options/impl#[FormatSizeOptions]from().(from: FormatSizeOptionsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions#) -> FormatSizeOptionsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions# {
123 FormatSizeOptionsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions# { ..from }
124 }
125
126 pub fn base_unitrust-analyzer cargo humansize 2.1.3 options/impl#[FormatSizeOptions]base_unit().(mut self, base_unit: BaseUnitrust-analyzer cargo humansize 2.1.3 options/BaseUnit#) -> FormatSizeOptionsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions# {
127 self.base_unitrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions#base_unit. = base_unit;
128 self
129 }
130
131 pub fn kilorust-analyzer cargo humansize 2.1.3 options/impl#[FormatSizeOptions]kilo().(mut self, kilo: Kilorust-analyzer cargo humansize 2.1.3 options/Kilo#) -> FormatSizeOptionsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions# {
132 self.kilorust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions#kilo. = kilo;
133 self
134 }
135
136 pub fn unitsrust-analyzer cargo humansize 2.1.3 options/impl#[FormatSizeOptions]units().(mut self, units: Kilorust-analyzer cargo humansize 2.1.3 options/Kilo#) -> FormatSizeOptionsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions# {
137 self.unitsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions#units. = units;
138 self
139 }
140
141 pub fn decimal_placesrust-analyzer cargo humansize 2.1.3 options/impl#[FormatSizeOptions]decimal_places().(mut self, decimal_places: usize) -> FormatSizeOptionsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions# {
142 self.decimal_placesrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions#decimal_places. = decimal_places;
143 self
144 }
145
146 pub fn decimal_zeroesrust-analyzer cargo humansize 2.1.3 options/impl#[FormatSizeOptions]decimal_zeroes().(mut self, decimal_zeroes: usize) -> FormatSizeOptionsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions# {
147 self.decimal_zeroesrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions#decimal_zeroes. = decimal_zeroes;
148 self
149 }
150
151 pub fn fixed_atrust-analyzer cargo humansize 2.1.3 options/impl#[FormatSizeOptions]fixed_at().(mut self, fixed_at: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<FixedAtrust-analyzer cargo humansize 2.1.3 options/FixedAt#>) -> FormatSizeOptionsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions# {
152 self.fixed_atrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions#fixed_at. = fixed_at;
153 self
154 }
155
156 pub fn long_unitsrust-analyzer cargo humansize 2.1.3 options/impl#[FormatSizeOptions]long_units().(mut self, long_units: bool) -> FormatSizeOptionsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions# {
157 self.long_unitsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions#long_units. = long_units;
158 self
159 }
160
161 pub fn space_after_valuerust-analyzer cargo humansize 2.1.3 options/impl#[FormatSizeOptions]space_after_value().(mut self, insert_space: bool) -> FormatSizeOptionsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions# {
162 self.space_after_valuerust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions#space_after_value. = insert_space;
163 self
164 }
165
166 pub fn suffixrust-analyzer cargo humansize 2.1.3 options/impl#[FormatSizeOptions]suffix().(mut self, suffix: &'static str) -> FormatSizeOptionsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions# {
167 self.suffixrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions#suffix. = suffix;
168 self
169 }
170 }
171
172 impl AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<FormatSizeOptionsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions#> for FormatSizeOptionsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions# {
173 fn as_refrust-analyzer cargo humansize 2.1.3 options/impl#[FormatSizeOptions][`AsRef<Self>`]as_ref().(&self) -> &FormatSizeOptionsrust-analyzer cargo humansize 2.1.3 options/FormatSizeOptions# {
174 self
175 }
176 }