#[non_exhaustive]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Encoding {
Utf8,
Utf16Le,
Utf16Be,
Utf32Le,
Utf32Be,
}
impl Encoding {
#[must_use]
pub const fn name(self) -> &'static str {
match self {
Self::Utf8 => "UTF-8",
Self::Utf16Le => "UTF-16LE",
Self::Utf16Be => "UTF-16BE",
Self::Utf32Le => "UTF-32LE",
Self::Utf32Be => "UTF-32BE",
}
}
}
#[cfg(test)]
mod tests {
use super::Encoding;
#[test]
fn names() {
assert_eq!(Encoding::Utf8.name(), "UTF-8");
assert_eq!(Encoding::Utf16Le.name(), "UTF-16LE");
assert_eq!(Encoding::Utf16Be.name(), "UTF-16BE");
assert_eq!(Encoding::Utf32Le.name(), "UTF-32LE");
assert_eq!(Encoding::Utf32Be.name(), "UTF-32BE");
}
}