deserialize-file-size

A serde helper function for deserializing file size input flexibly and robustly.

Accepts either:

1) a "human" size string, e.g. "1k", "5mb", "12GiB", etc. 2) an integer number of bytes

Example

```rust use serde::Deserialize; use deserializefilesize::deserializefilesize;

[derive(Deserialize, Debug, PartialEq)]

struct FileSize { #[serde(deserializewith = "deserializefile_size")] sz: usize, }

let sizestr = r#"{"sz": "42mb"}"#; asserteq!( serdejson::fromstr::(size_str).unwrap(), FileSize { sz: 1024 * 1024 * 42 }, );

let intbytes = r#"{"sz": 4096}"#; asserteq!( serdejson::fromstr::(int_bytes).unwrap(), FileSize { sz: 4096 }, ); ```