Skip to main content

SizeExt

Trait SizeExt 

Source
pub trait SizeExt {
    // Required methods
    fn bytes(self) -> ByteSize;
    fn kib(self) -> ByteSize;
    fn mib(self) -> ByteSize;
    fn gib(self) -> ByteSize;
}
Expand description

Helper trait for readable byte sizes.

Implemented for common integer types so that literals like 512.mib() or 1.gib() return a ByteSize that converts into either Bytes or Mebibytes.

Required Methods§

Source

fn bytes(self) -> ByteSize

Create a ByteSize representing this many bytes.

Source

fn kib(self) -> ByteSize

Create a ByteSize representing this many kibibytes (×1024).

Source

fn mib(self) -> ByteSize

Create a ByteSize representing this many mebibytes (×1024²).

Source

fn gib(self) -> ByteSize

Create a ByteSize representing this many gibibytes (×1024³).

Implementations on Foreign Types§

Source§

impl SizeExt for i32

Source§

fn bytes(self) -> ByteSize

Source§

fn kib(self) -> ByteSize

Source§

fn mib(self) -> ByteSize

Source§

fn gib(self) -> ByteSize

Source§

impl SizeExt for u8

Source§

fn bytes(self) -> ByteSize

Source§

fn kib(self) -> ByteSize

Source§

fn mib(self) -> ByteSize

Source§

fn gib(self) -> ByteSize

Source§

impl SizeExt for u16

Source§

fn bytes(self) -> ByteSize

Source§

fn kib(self) -> ByteSize

Source§

fn mib(self) -> ByteSize

Source§

fn gib(self) -> ByteSize

Source§

impl SizeExt for u32

Source§

fn bytes(self) -> ByteSize

Source§

fn kib(self) -> ByteSize

Source§

fn mib(self) -> ByteSize

Source§

fn gib(self) -> ByteSize

Source§

impl SizeExt for u64

Source§

fn bytes(self) -> ByteSize

Source§

fn kib(self) -> ByteSize

Source§

fn mib(self) -> ByteSize

Source§

fn gib(self) -> ByteSize

Source§

impl SizeExt for usize

Source§

fn bytes(self) -> ByteSize

Source§

fn kib(self) -> ByteSize

Source§

fn mib(self) -> ByteSize

Source§

fn gib(self) -> ByteSize

Implementors§