simple snappy bindings, enabling alloc free code

This commit is contained in:
Robert Habermeier
2016-06-13 17:44:50 +02:00
parent b88eef5374
commit 75013003f7
3 changed files with 150 additions and 0 deletions

View File

@@ -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 {