mirror of
https://github.com/mbilker/kbinxml-rs.git
synced 2026-04-24 23:17:15 -05:00
kbinxml: fix compatibility with older Rust versions
This commit is contained in:
parent
5e9992a436
commit
ce0764af58
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user