#[derive(Clone, Copy, PartialEq, Eq, Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error(
"a value contains `\\` before {0:?}; only `\\\\`, `\\{{`, `\\|` and `\\}}` pass through to the message"
)]
LoneBackslash(char),
#[error("a value ends in `\\`, which the resource syntax cannot represent")]
TrailingBackslash,
#[error("{0} cannot contain {1:?}: the resource syntax has no escape for it there")]
Unrepresentable(Role, char),
#[error("{0} is empty")]
Empty(Role),
}
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[non_exhaustive]
pub enum Role {
Id,
IdPart,
PropertyName,
Comment,
}
impl core::fmt::Display for Role {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.write_str(match self {
Role::Id => "an id",
Role::IdPart => "an id part",
Role::PropertyName => "a property name",
Role::Comment => "a comment",
})
}
}