tests for data ser/de

This commit is contained in:
NikVolf
2017-04-03 18:15:13 +03:00
parent a63f31a0f7
commit 5979248f2f
4 changed files with 88 additions and 3 deletions

View File

@ -85,4 +85,10 @@ pub fn deserialize_file<P: AsRef<::std::path::Path>>(p: P) -> Result<Module, Err
pub fn deserialize_buffer<T: Deserialize>(contents: Vec<u8>) -> Result<T, T::Error> {
let mut reader = io::Cursor::new(contents);
T::deserialize(&mut reader)
}
pub fn serialize<T: Serialize>(val: T) -> Result<Vec<u8>, T::Error> {
let mut buf = Vec::new();
val.serialize(&mut buf)?;
Ok(buf)
}