Skip to main content

zyn_core/path/
error.rs

1/// An error that occurs when parsing a [`MetaPath`](super::MetaPath).
2#[derive(Clone, Debug, PartialEq, Eq)]
3pub enum ParseError {
4    /// The path string is empty.
5    Empty,
6    /// An index bracket was not closed (missing `]`).
7    UnclosedBracket,
8    /// The contents of `[...]` could not be parsed as a number.
9    InvalidIndex(String),
10}
11
12impl std::fmt::Display for ParseError {
13    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14        match self {
15            Self::Empty => write!(f, "empty path"),
16            Self::UnclosedBracket => write!(f, "unclosed bracket"),
17            Self::InvalidIndex(s) => write!(f, "invalid index: {}", s),
18        }
19    }
20}
21
22impl std::error::Error for ParseError {}