pub enum DurationError {
InvalidCharacter(usize),
NumberExpected(usize),
UnknownUnit {
start: usize,
end: usize,
unit: String,
value: u64,
},
NumberOverflow,
Empty,
}
Expand description
Error parsing human-friendly duration
Variants§
InvalidCharacter(usize)
Invalid character during parsing
More specifically anything that is not alphanumeric is prohibited
The field is an byte offset of the character in the string.
NumberExpected(usize)
Non-numeric value where number is expected
This usually means that either time unit is broken into words,
e.g. m sec
instead of msec
, or just number is omitted,
for example 2 hours min
instead of 2 hours 1 min
The field is an byte offset of the errorneous character in the string.
UnknownUnit
Unit in the number is not one of allowed units
See documentation of parse_duration
for the list of supported
time units.
The two fields are start and end (exclusive) of the slice from the original string, containing errorneous value
Fields
NumberOverflow
The numeric value exceeds the limits of this library.
This can mean two things:
- The value is too large to be useful. For instance, the maximum duration written with subseconds unit is about 3000 years.
- The attempted precision is not supported.
For instance, a duration of
0.5ns
is not supported, because durations below one nanosecond cannot be represented.
Empty
The value was an empty string (or consists only whitespace)