#[derive(Clone, Copy, PartialEq, Eq, Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error("text or literal contains U+0000, which MF2 syntax cannot represent")]
Nul,
#[error("{0} is not a valid MF2 name")]
InvalidName(NameRole),
#[error("an input declaration's name differs from its variable's name")]
InputNameMismatch,
#[error("a select message needs at least one selector")]
NoSelectors,
#[error("a select message needs at least one variant")]
NoVariants,
#[error("a variant needs at least one key")]
NoKeys,
#[error("a part of the message of an unknown kind")]
UnknownNode,
}
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[non_exhaustive]
pub enum NameRole {
Variable,
Function,
Option,
Markup,
Attribute,
}
impl core::fmt::Display for NameRole {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.write_str(match self {
NameRole::Variable => "a variable name",
NameRole::Function => "a function identifier",
NameRole::Option => "an option identifier",
NameRole::Markup => "a markup identifier",
NameRole::Attribute => "an attribute identifier",
})
}
}