Struct humansize::FormatSizeOptions
source · #[non_exhaustive]pub struct FormatSizeOptions {
pub base_unit: BaseUnit,
pub kilo: Kilo,
pub units: Kilo,
pub decimal_places: usize,
pub decimal_zeroes: usize,
pub fixed_at: Option<FixedAt>,
pub long_units: bool,
pub space_after_value: bool,
pub suffix: &'static str,
}
Expand description
Holds the options for the file_size
method.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.base_unit: BaseUnit
Whether the value being formatted represents an amount of bits or bytes.
kilo: Kilo
The scale (binary/decimal) to divide against.
units: Kilo
The unit set to display.
decimal_places: usize
The amount of decimal places to display if the decimal part is non-zero.
decimal_zeroes: usize
The amount of zeroes to display if the decimal part is zero.
fixed_at: Option<FixedAt>
Whether to force a certain representation and if so, which one.
long_units: bool
Whether to use the full unit (e.g. Kilobyte
) or its abbreviation (kB
).
space_after_value: bool
Whether to place a space between value and units.
suffix: &'static str
An optional suffix which will be appended after the unit. Useful to represent speeds (e.g. `1 kB/s)
Implementations§
source§impl FormatSizeOptions
impl FormatSizeOptions
sourcepub fn from(from: FormatSizeOptions) -> FormatSizeOptions
pub fn from(from: FormatSizeOptions) -> FormatSizeOptions
pub fn base_unit(self, base_unit: BaseUnit) -> FormatSizeOptions
pub fn kilo(self, kilo: Kilo) -> FormatSizeOptions
pub fn units(self, units: Kilo) -> FormatSizeOptions
sourcepub fn decimal_places(self, decimal_places: usize) -> FormatSizeOptions
pub fn decimal_places(self, decimal_places: usize) -> FormatSizeOptions
pub fn decimal_zeroes(self, decimal_zeroes: usize) -> FormatSizeOptions
pub fn fixed_at(self, fixed_at: Option<FixedAt>) -> FormatSizeOptions
pub fn long_units(self, long_units: bool) -> FormatSizeOptions
pub fn space_after_value(self, insert_space: bool) -> FormatSizeOptions
pub fn suffix(self, suffix: &'static str) -> FormatSizeOptions
Trait Implementations§
source§impl AsRef<FormatSizeOptions> for FormatSizeOptions
impl AsRef<FormatSizeOptions> for FormatSizeOptions
source§fn as_ref(&self) -> &FormatSizeOptions
fn as_ref(&self) -> &FormatSizeOptions
Converts this type into a shared reference of the (usually inferred) input type.
source§impl Clone for FormatSizeOptions
impl Clone for FormatSizeOptions
source§fn clone(&self) -> FormatSizeOptions
fn clone(&self) -> FormatSizeOptions
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for FormatSizeOptions
impl Debug for FormatSizeOptions
source§impl Default for FormatSizeOptions
impl Default for FormatSizeOptions
source§fn default() -> FormatSizeOptions
fn default() -> FormatSizeOptions
Returns the “default value” for a type. Read more