humansize

Trait 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());

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so 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§