Enum humantime::DurationError
source · [−]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
Fields
start: usize
Start of the invalid unit inside the original string
end: usize
End of the invalid unit inside the original string
unit: String
The unit verbatim
value: u64
A number associated with the unit
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
NumberOverflow
The numeric value is too large
Usually this means value is too large to be useful. If user writes data in subsecond units, then the maximum is about 3k years. When using seconds, or larger units, the limit is even larger.
Empty
The value was an empty string (or consists only whitespace)
Trait Implementations
sourceimpl Error for Error
impl Error for Error
1.30.0 · sourcefn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
sourcefn backtrace(&self) -> Option<&Backtrace>
fn backtrace(&self) -> Option<&Backtrace>
backtrace
)Returns a stack backtrace, if available, of where this error occurred. Read more
1.0.0 · sourcefn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
impl StructuralPartialEq for Error
Auto Trait Implementations
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnwindSafe for Error
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more