1use std::fmt::Display;
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum DznParseError {
8 #[error("failed to read from source: {0}")]
9 Io(#[from] std::io::Error),
10 #[error("failed to decode to UTF-8 string: {0}")]
11 InvalidEncoding(#[from] std::str::Utf8Error),
12 #[error("failed to parse DZN: expected '{expected}' but got '{actual}'")]
13 InvalidSyntax {
14 expected: SyntaxElement,
15 actual: String,
16 },
17}
18
19#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
21pub enum SyntaxElement {
22 Identifier,
24 Value,
26 Equals,
28 SemiColon,
30}
31
32impl Display for SyntaxElement {
33 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
34 match self {
35 SyntaxElement::Identifier => write!(f, "identifier"),
36 SyntaxElement::Value => write!(f, "value"),
37 SyntaxElement::Equals => write!(f, "="),
38 SyntaxElement::SemiColon => write!(f, ";"),
39 }
40 }
41}