nushell/crates/nu-protocol/src/value
Ian Manske 7f61cbbfd6
Add Filesize type (#14369)
# Description
Adds a new `Filesize` type so that `FromValue` can be used to convert a
`Value::Filesize` to a `Filesize`. Currently, to extract a filesize from
a `Value` using `FromValue`, you have to extract an `i64` which coerces
`Value::Int`, `Value::Duration`, and `Value::Filesize` to an `i64`.

Having a separate type also allows us to enforce checked math to catch
overflows. Similarly, it allows us to specify other trait
implementations like `Display` in a common place.

# User-Facing Changes
Multiplication with filesizes now error on overflow. Should not be a
breaking change for plugins (i.e., serialization) since `Filesize` is
marked with `serde(transparent)`.

# Tests + Formatting
Updated some tests.
2024-11-29 21:24:17 +00:00
..
custom_value.rs Make drop notification timing for plugin custom values more consistent (#12341) 2024-04-04 09:13:25 +02:00
duration.rs Restructure nu-protocol in more meaningful units (#11917) 2024-03-10 18:45:45 +01:00
filesize.rs Add Filesize type (#14369) 2024-11-29 21:24:17 +00:00
from_value.rs Add Filesize type (#14369) 2024-11-29 21:24:17 +00:00
glob.rs ls, rm, cp, open, touch, mkdir: Don't expand tilde if input path is quoted string or a variable. (#12232) 2024-03-25 10:08:38 +08:00
into_value.rs Add #[nu_value(rename = "...")] as helper attribute on members for derive macros (#13761) 2024-09-04 11:27:21 +02:00
mod.rs Add Filesize type (#14369) 2024-11-29 21:24:17 +00:00
range.rs Fix range contains (#14011) 2024-10-22 10:34:41 -05:00
record.rs Document public types in nu-protocol (#12906) 2024-07-11 13:30:12 +02:00
test_derive.rs Add #[nu_value(rename = "...")] as helper attribute on members for derive macros (#13761) 2024-09-04 11:27:21 +02:00