1 //! Error parsing an input into a [`Parsed`](crate::parsing::Parsed) struct
7 /// An error that occurred while parsing the input into a [`Parsed`](crate::parsing::Parsed) struct.
9 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
10 pub enum ParseFromDescription
{
11 /// A string literal was not what was expected.
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.
18 UnexpectedTrailingCharacters
,
21 impl fmt
::Display
for ParseFromDescription
{
22 fn fmt(&self, f
: &mut fmt
::Formatter
<'_
>) -> fmt
::Result
{
24 Self::InvalidLiteral
=> f
.write_str("a character literal was not valid"),
25 Self::InvalidComponent(name
) => {
26 write
!(f
, "the '{name}' component could not be parsed")
28 Self::UnexpectedTrailingCharacters
=> {
29 f
.write_str("unexpected trailing characters; the end of input was expected")
35 #[cfg(feature = "std")]
36 impl std
::error
::Error
for ParseFromDescription {}
38 impl From
<ParseFromDescription
> for crate::Error
{
39 fn from(original
: ParseFromDescription
) -> Self {
40 Self::ParseFromDescription(original
)
44 impl TryFrom
<crate::Error
> for ParseFromDescription
{
45 type Error
= error
::DifferentVariant
;
47 fn try_from(err
: crate::Error
) -> Result
<Self, Self::Error
> {
49 crate::Error
::ParseFromDescription(err
) => Ok(err
),
50 _
=> Err(error
::DifferentVariant
),