pub struct Size { /* private fields */ }Expand description
Non-negative size in bytes. Constructors round fractional inputs
up; negative or NaN inputs return Error::Argument.
Implementations§
Source§impl Size
impl Size
Sourcepub fn from_bytes(b: f64) -> Result<Self, Error>
pub fn from_bytes(b: f64) -> Result<Self, Error>
Build from a byte count (rounded up if fractional).
Sourcepub fn from_kilobytes(k: f64) -> Result<Self, Error>
pub fn from_kilobytes(k: f64) -> Result<Self, Error>
Build from kilobytes (1 kB = 1000 B).
Sourcepub fn from_megabytes(m: f64) -> Result<Self, Error>
pub fn from_megabytes(m: f64) -> Result<Self, Error>
Build from megabytes.
Sourcepub fn from_gigabytes(g: f64) -> Result<Self, Error>
pub fn from_gigabytes(g: f64) -> Result<Self, Error>
Build from gigabytes.
Sourcepub fn from_terabytes(t: f64) -> Result<Self, Error>
pub fn from_terabytes(t: f64) -> Result<Self, Error>
Build from terabytes.
Sourcepub fn parse(s: &str) -> Result<Self, Error>
pub fn parse(s: &str) -> Result<Self, Error>
Parse strings like "28MB", "1gb", "512 kb",
"2megabytes". Case-insensitive, whitespace-tolerant. Accepts
decimal values ("1.5gb") and concatenated parts (e.g.
"1gb 256mb"). See FromStr.
Sourcepub fn to_kilobytes(self) -> f64
pub fn to_kilobytes(self) -> f64
Fractional kilobytes.
Sourcepub fn to_megabytes(self) -> f64
pub fn to_megabytes(self) -> f64
Fractional megabytes.
Sourcepub fn to_gigabytes(self) -> f64
pub fn to_gigabytes(self) -> f64
Fractional gigabytes.
Sourcepub fn to_terabytes(self) -> f64
pub fn to_terabytes(self) -> f64
Fractional terabytes.
Trait Implementations§
Source§impl Ord for Size
impl Ord for Size
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Size
impl PartialOrd for Size
impl Copy for Size
impl Eq for Size
impl StructuralPartialEq for Size
Auto Trait Implementations§
impl Freeze for Size
impl RefUnwindSafe for Size
impl Send for Size
impl Sync for Size
impl Unpin for Size
impl UnsafeUnpin for Size
impl UnwindSafe for Size
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.