simple snappy bindings, enabling alloc free code
This commit is contained in:
@@ -65,6 +65,8 @@ pub enum UtilError {
|
||||
SimpleString(String),
|
||||
/// Error from a bad input size being given for the needed output.
|
||||
BadSize,
|
||||
/// Error from snappy.
|
||||
Snappy(::snappy::Error),
|
||||
}
|
||||
|
||||
impl fmt::Display for UtilError {
|
||||
@@ -82,6 +84,7 @@ impl fmt::Display for UtilError {
|
||||
UtilError::Decoder(ref err) => f.write_fmt(format_args!("{}", err)),
|
||||
UtilError::SimpleString(ref msg) => f.write_str(&msg),
|
||||
UtilError::BadSize => f.write_str("Bad input size."),
|
||||
UtilError::Snappy(ref err) => f.write_fmt(format_args!("{}", err)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,6 +182,12 @@ impl From<String> for UtilError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<::snappy::Error> for UtilError {
|
||||
fn from(err: ::snappy::Error) -> UtilError {
|
||||
UtilError::Snappy(err)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: uncomment below once https://github.com/rust-lang/rust/issues/27336 sorted.
|
||||
/*#![feature(concat_idents)]
|
||||
macro_rules! assimilate {
|
||||
|
||||
Reference in New Issue
Block a user