1use core::fmt;
2#[cfg(feature = "std")]
3use std::error::Error;
4
5#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
7pub enum ParseError {
8 InvalidLength,
10 NodeCapacityExceeded,
12 StackCapacityExceeded,
14 RootCapacityExceeded,
16 AttributeCapacityExceeded,
18 ChildCapacityExceeded,
20 IdCapacityExceeded,
22 ClassCapacityExceeded,
24 SelectorCapacityExceeded,
26}
27
28impl fmt::Display for ParseError {
29 fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
30 match self {
31 ParseError::InvalidLength => {
32 write!(f, "The input string length is too large to fit in a `u32`")
33 }
34 ParseError::NodeCapacityExceeded => {
35 write!(f, "The configured node capacity was exceeded")
36 }
37 ParseError::StackCapacityExceeded => {
38 write!(f, "The configured stack capacity was exceeded")
39 }
40 ParseError::RootCapacityExceeded => {
41 write!(f, "The configured root-node capacity was exceeded")
42 }
43 ParseError::AttributeCapacityExceeded => {
44 write!(f, "The configured attribute capacity was exceeded")
45 }
46 ParseError::ChildCapacityExceeded => {
47 write!(f, "The configured child capacity was exceeded")
48 }
49 ParseError::IdCapacityExceeded => {
50 write!(f, "The configured ID index capacity was exceeded")
51 }
52 ParseError::ClassCapacityExceeded => {
53 write!(f, "The configured class index capacity was exceeded")
54 }
55 ParseError::SelectorCapacityExceeded => {
56 write!(f, "The configured query selector capacity was exceeded")
57 }
58 }
59 }
60}
61
62#[cfg(feature = "std")]
63impl Error for ParseError {}
64
65#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
67pub enum SetBytesError {
68 LengthOverflow,
70}
71
72impl fmt::Display for SetBytesError {
73 fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
74 match self {
75 SetBytesError::LengthOverflow => {
76 write!(f, "The string length is too large to fit in a `u32`")
77 }
78 }
79 }
80}
81
82#[cfg(feature = "std")]
83impl Error for SetBytesError {}