use core::fmt;
#[derive(Debug, PartialEq, Eq)]
pub enum Error {
NodeEmpty,
ResourceEmpty,
NodeTooLong,
ResourceTooLong,
NodePrep,
NamePrep,
ResourcePrep,
ResourceMissingInFullJid,
ResourceInBareJid,
TooManyAts,
Idna,
}
impl core::error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.write_str(match self {
Error::NodeEmpty => "nodepart empty despite the presence of a @",
Error::ResourceEmpty => "resource empty despite the presence of a /",
Error::NodeTooLong => "localpart longer than 1023 bytes",
Error::ResourceTooLong => "resource longer than 1023 bytes",
Error::NodePrep => "localpart doesn’t pass nodeprep validation",
Error::NamePrep => "domain doesn’t pass nameprep validation",
Error::ResourcePrep => "resource doesn’t pass resourceprep validation",
Error::ResourceMissingInFullJid => "no resource found in this full JID",
Error::ResourceInBareJid => "resource found while parsing a bare JID",
Error::TooManyAts => "second @ found before parsing the resource",
Error::Idna => "domain doesn’t pass idna validation",
})
}
}