time/error/
parse_from_description.rs

1//! Error parsing an input into a [`Parsed`](crate::parsing::Parsed) struct
2
3use core::fmt;
4
5use crate::error;
6
7/// An error that occurred while parsing the input into a [`Parsed`](crate::parsing::Parsed) struct.
8#[non_exhaustive]
9#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ParseFromDescription {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            ParseFromDescription::InvalidLiteral =>
                ::core::fmt::Formatter::write_str(f, "InvalidLiteral"),
            ParseFromDescription::InvalidComponent(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "InvalidComponent", &__self_0),
            ParseFromDescription::UnexpectedTrailingCharacters =>
                ::core::fmt::Formatter::write_str(f,
                    "UnexpectedTrailingCharacters"),
        }
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for ParseFromDescription {
    #[inline]
    fn clone(&self) -> ParseFromDescription {
        let _: ::core::clone::AssertParamIsClone<&'static str>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for ParseFromDescription { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for ParseFromDescription {
    #[inline]
    fn eq(&self, other: &ParseFromDescription) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (ParseFromDescription::InvalidComponent(__self_0),
                    ParseFromDescription::InvalidComponent(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ParseFromDescription {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_receiver_is_total_eq(&self) -> () {
        let _: ::core::cmp::AssertParamIsEq<&'static str>;
    }
}Eq)]
10pub enum ParseFromDescription {
11    /// A string literal was not what was expected.
12    #[non_exhaustive]
13    InvalidLiteral,
14    /// A dynamic component was not valid.
15    InvalidComponent(&'static str),
16    /// The input was expected to have ended, but there are characters that remain.
17    #[non_exhaustive]
18    UnexpectedTrailingCharacters,
19}
20
21impl fmt::Display for ParseFromDescription {
22    #[inline]
23    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24        match self {
25            Self::InvalidLiteral => f.write_str("a character literal was not valid"),
26            Self::InvalidComponent(name) => {
27                f.write_fmt(format_args!("the \'{0}\' component could not be parsed", name))write!(f, "the '{name}' component could not be parsed")
28            }
29            Self::UnexpectedTrailingCharacters => {
30                f.write_str("unexpected trailing characters; the end of input was expected")
31            }
32        }
33    }
34}
35
36impl core::error::Error for ParseFromDescription {}
37
38impl From<ParseFromDescription> for crate::Error {
39    #[inline]
40    fn from(original: ParseFromDescription) -> Self {
41        Self::ParseFromDescription(original)
42    }
43}
44
45impl TryFrom<crate::Error> for ParseFromDescription {
46    type Error = error::DifferentVariant;
47
48    #[inline]
49    fn try_from(err: crate::Error) -> Result<Self, Self::Error> {
50        match err {
51            crate::Error::ParseFromDescription(err) => Ok(err),
52            _ => Err(error::DifferentVariant),
53        }
54    }
55}