use ByteSize for byte size rendering / parsing, add same to duration - #3531
Conversation
|
Is it really worth it to add a new dependency for a type we could implement in less than 100 lines? |
I admit I can't judge the compile time difference, it's probably more than these 100 lines with the parsing & rendering, but even when it's 300/400 lines, plus tests? |
|
I don't even think we need 100 lines. We need |
I replaced the external crate with a simplified custom implementation, with less unnecessary features or speed, and with two added things that the lib didn't have. |
This started of as a part of the new
docs_rs_buildCLI, where I wanted to parse & render byte-sizes & durations consistently.The lead to doing that for
docs_rs_admintoo, which will make my life easier when using the admin CLI to work with crate limits.Then I thought about configuration, where the
.envfiles will also be much easier to read when we use human-readable values for durations & sizes.Then I fixed all the errors. Also, the
Durationtype offers some nice constructors since rust 1.91, so I changed that where I saw it. Thedocs_rs_env_varschange was necessary to handle theErrtype fromByteSize/FromStrwith our helpers.These are not yet all places, and not yet the perfect design (I tried to prevent a
ByteSizenewtype for now).