pub trait FileSize {
// Required method
fn file_size<T: AsRef<FileSizeOpts>>(
&self,
opts: T,
) -> Result<String, String>;
}
Expand description
The trait for the file_size
method
Required Methods§
sourcefn file_size<T: AsRef<FileSizeOpts>>(&self, opts: T) -> Result<String, String>
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.