Upgrade byteorder to 0.5.x (#68)
This commit is contained in:
parent
e5e74307fa
commit
183c28e363
|
|
@ -12,7 +12,7 @@ description = "A binary serialization / deserialization strategy and implementat
|
|||
|
||||
[dependencies]
|
||||
rustc-serialize = "0.3.*"
|
||||
byteorder = "0.4.*"
|
||||
byteorder = "0.5.*"
|
||||
num = "0.1.*"
|
||||
serde = "0.7.*"
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ use std::convert::From;
|
|||
use rustc_serialize_crate::Decoder;
|
||||
|
||||
use byteorder::{BigEndian, ReadBytesExt};
|
||||
use byteorder::Error as ByteOrderError;
|
||||
use ::SizeLimit;
|
||||
|
||||
#[derive(Eq, PartialEq, Clone, Debug)]
|
||||
|
|
@ -61,15 +60,8 @@ impl fmt::Display for DecodingError {
|
|||
|
||||
pub type DecodingResult<T> = Result<T, DecodingError>;
|
||||
|
||||
fn wrap_io(err: ByteOrderError) -> DecodingError {
|
||||
match err {
|
||||
ByteOrderError::Io(ioe) => DecodingError::IoError(ioe),
|
||||
ByteOrderError::UnexpectedEOF =>
|
||||
DecodingError::InvalidEncoding(InvalidEncoding {
|
||||
desc: "Unexpected EOF while reading a multi-byte number",
|
||||
detail: None
|
||||
})
|
||||
}
|
||||
fn wrap_io(err: IoError) -> DecodingError {
|
||||
DecodingError::IoError(err)
|
||||
}
|
||||
|
||||
impl Error for DecodingError {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
use std::io::Write;
|
||||
use std::io::Error as IoError;
|
||||
use std::io::ErrorKind as IoErrorKind;
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
|
||||
use rustc_serialize_crate::Encoder;
|
||||
|
||||
use byteorder::{BigEndian, WriteBytesExt};
|
||||
use byteorder::Error as ByteOrderError;
|
||||
|
||||
pub type EncodingResult<T> = Result<T, EncodingError>;
|
||||
|
||||
|
|
@ -37,13 +35,8 @@ pub struct SizeChecker {
|
|||
pub written: u64
|
||||
}
|
||||
|
||||
fn wrap_io(err: ByteOrderError) -> EncodingError {
|
||||
match err {
|
||||
ByteOrderError::Io(ioe) => EncodingError::IoError(ioe),
|
||||
ByteOrderError::UnexpectedEOF => EncodingError::IoError(
|
||||
IoError::new(IoErrorKind::Other,
|
||||
"ByteOrder could not write to the buffer"))
|
||||
}
|
||||
fn wrap_io(err: IoError) -> EncodingError {
|
||||
EncodingError::IoError(err)
|
||||
}
|
||||
|
||||
impl fmt::Display for EncodingError {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ use std::error::Error;
|
|||
use std::fmt;
|
||||
use std::convert::From;
|
||||
|
||||
use byteorder::Error as ByteOrderError;
|
||||
use byteorder::{BigEndian, ReadBytesExt};
|
||||
use num;
|
||||
use serde_crate as serde;
|
||||
|
|
@ -77,16 +76,6 @@ impl From<IoError> for DeserializeError {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<ByteOrderError> for DeserializeError {
|
||||
fn from(err: ByteOrderError) -> DeserializeError {
|
||||
match err {
|
||||
ByteOrderError::Io(ioe) => DeserializeError::IoError(ioe),
|
||||
ByteOrderError::UnexpectedEOF => DeserializeError::Serde(
|
||||
serde::de::value::Error::EndOfStream),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<serde::de::value::Error> for DeserializeError {
|
||||
fn from(err: serde::de::value::Error) -> DeserializeError {
|
||||
DeserializeError::Serde(err)
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
use std::error::Error;
|
||||
use std::fmt;
|
||||
use std::io::Error as IoError;
|
||||
use std::io::ErrorKind as IoErrorKind;
|
||||
use std::io::Write;
|
||||
use std::u32;
|
||||
|
||||
use serde_crate as serde;
|
||||
|
||||
use byteorder::{BigEndian, WriteBytesExt};
|
||||
use byteorder::Error as ByteOrderError;
|
||||
|
||||
pub type SerializeResult<T> = Result<T, SerializeError>;
|
||||
|
||||
|
|
@ -35,13 +33,8 @@ pub struct Serializer<'a, W: 'a> {
|
|||
writer: &'a mut W,
|
||||
}
|
||||
|
||||
fn wrap_io(err: ByteOrderError) -> SerializeError {
|
||||
match err {
|
||||
ByteOrderError::Io(ioe) => SerializeError::IoError(ioe),
|
||||
ByteOrderError::UnexpectedEOF => SerializeError::IoError(
|
||||
IoError::new(IoErrorKind::Other,
|
||||
"ByteOrder could not write to the buffer"))
|
||||
}
|
||||
fn wrap_io(err: IoError) -> SerializeError {
|
||||
SerializeError::IoError(err)
|
||||
}
|
||||
|
||||
impl serde::ser::Error for SerializeError {
|
||||
|
|
|
|||
Loading…
Reference in New Issue