kbinxml: fix compatibility with older Rust versions

This commit is contained in:
Matt Bilker 2019-12-09 20:47:04 +00:00
parent 5e9992a436
commit ce0764af58
No known key found for this signature in database
GPG Key ID: 69ADF8AEB6C8B5D1
3 changed files with 9 additions and 9 deletions

View File

@ -15,23 +15,23 @@ pub struct UnknownCompression(u8);
impl CompressionType {
pub fn from_byte(byte: u8) -> Result<Self, UnknownCompression> {
match byte {
SIG_COMPRESSED => Ok(Self::Compressed),
SIG_UNCOMPRESSED => Ok(Self::Uncompressed),
SIG_COMPRESSED => Ok(CompressionType::Compressed),
SIG_UNCOMPRESSED => Ok(CompressionType::Uncompressed),
_ => Err(UnknownCompression(byte)),
}
}
pub fn to_byte(&self) -> u8 {
match *self {
Self::Compressed => SIG_COMPRESSED,
Self::Uncompressed => SIG_UNCOMPRESSED,
CompressionType::Compressed => SIG_COMPRESSED,
CompressionType::Uncompressed => SIG_UNCOMPRESSED,
}
}
}
impl Default for CompressionType {
fn default() -> Self {
Self::Compressed
CompressionType::Compressed
}
}

View File

@ -27,8 +27,8 @@ impl fmt::Display for KbinType {
impl fmt::Display for UnknownKbinType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::Byte(byte) => write!(f, "Unknown or not implemented type: {}", byte),
Self::Name(name) => write!(f, "Unknown or not implemented name: {}", name),
UnknownKbinType::Byte(byte) => write!(f, "Unknown or not implemented type: {}", byte),
UnknownKbinType::Name(name) => write!(f, "Unknown or not implemented name: {}", name),
}
}
}

View File

@ -63,14 +63,14 @@ pub enum TextReaderError {
impl From<Utf8Error> for TextReaderError {
#[inline]
fn from(source: Utf8Error) -> Self {
Self::Utf8 { source }
TextReaderError::Utf8 { source }
}
}
impl From<QuickXmlError> for TextReaderError {
#[inline]
fn from(source: QuickXmlError) -> Self {
Self::Xml { source }
TextReaderError::Xml { source }
}
}