Trait humansize::FileSize

source ·
pub trait FileSize {
    // Required method
    fn file_size<T: AsRef<FileSizeOpts>>(
        &self,
        opts: T,
    ) -> Result<String, String>;
}
Expand description

The trait for the file_sizemethod

Required Methods§

source

fn file_size<T: AsRef<FileSizeOpts>>(&self, opts: T) -> Result<String, String>

Formats self according to the parameters in opts. opts can either be one of the three defaults providedby the file_size_opts module, or be custom-defined according to your needs

§Errors

Will fail by default if called on a negative number. Override this behavior by setting allow_negative to True in a custom options struct.

§Examples
use humansize::{FileSize, file_size_opts as options};

let size = 5128;
println!("Size is {}", size.file_size(options::DECIMAL).unwrap());

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl FileSize for i8

source§

fn file_size<T: AsRef<FileSizeOpts>>(&self, _opts: T) -> Result<String, String>

source§

impl FileSize for i16

source§

fn file_size<T: AsRef<FileSizeOpts>>(&self, _opts: T) -> Result<String, String>

source§

impl FileSize for i32

source§

fn file_size<T: AsRef<FileSizeOpts>>(&self, _opts: T) -> Result<String, String>

source§

impl FileSize for i64

source§

fn file_size<T: AsRef<FileSizeOpts>>(&self, _opts: T) -> Result<String, String>

source§

impl FileSize for isize

source§

fn file_size<T: AsRef<FileSizeOpts>>(&self, _opts: T) -> Result<String, String>

source§

impl FileSize for u8

source§

fn file_size<T: AsRef<FileSizeOpts>>(&self, _opts: T) -> Result<String, String>

source§

impl FileSize for u16

source§

fn file_size<T: AsRef<FileSizeOpts>>(&self, _opts: T) -> Result<String, String>

source§

impl FileSize for u32

source§

fn file_size<T: AsRef<FileSizeOpts>>(&self, _opts: T) -> Result<String, String>

source§

impl FileSize for u64

source§

fn file_size<T: AsRef<FileSizeOpts>>(&self, _opts: T) -> Result<String, String>

source§

impl FileSize for usize

source§

fn file_size<T: AsRef<FileSizeOpts>>(&self, _opts: T) -> Result<String, String>

Implementors§