mirror of
https://github.com/mbilker/kbinxml-rs.git
synced 2026-09-09 19:15:27 -05:00
encoding_type: add Display implementation
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use std::fmt;
|
||||
|
||||
use error::{KbinError, KbinErrorKind};
|
||||
use failure::ResultExt;
|
||||
|
||||
@@ -24,6 +26,21 @@ impl Default for EncodingType {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for EncodingType {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let encoding = match *self {
|
||||
EncodingType::None => "None",
|
||||
EncodingType::ASCII => "ASCII",
|
||||
EncodingType::ISO_8859_1 => "ISO-8859-1",
|
||||
EncodingType::EUC_JP => "EUC-JP",
|
||||
EncodingType::SHIFT_JIS => "SHIFT-JIS",
|
||||
EncodingType::UTF_8 => "UTF-8",
|
||||
};
|
||||
|
||||
write!(f, "{}", encoding)
|
||||
}
|
||||
}
|
||||
|
||||
impl EncodingType {
|
||||
pub fn from_byte(byte: u8) -> Result<Self, KbinError> {
|
||||
let val = match byte {
|
||||
|
||||
Reference in New Issue
Block a user