mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-22 19:21:59 +00:00
128-bit packed serialization
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
use std::io;
|
||||
use std::io::Write;
|
||||
use super::{
|
||||
Serialize,
|
||||
Deserialize,
|
||||
Unparsed,
|
||||
Error,
|
||||
@ -15,6 +17,7 @@ use super::{
|
||||
FuncBody,
|
||||
ElementSegment,
|
||||
DataSegment,
|
||||
CountedWriter,
|
||||
};
|
||||
|
||||
use super::types::Type;
|
||||
@ -279,7 +282,7 @@ impl DataSection {
|
||||
}
|
||||
|
||||
impl Deserialize for DataSection {
|
||||
type Error = Error;
|
||||
type Error = Error;
|
||||
|
||||
fn deserialize<R: io::Read>(reader: &mut R) -> Result<Self, Self::Error> {
|
||||
// todo: maybe use reader.take(section_length)
|
||||
@ -289,6 +292,18 @@ impl Deserialize for DataSection {
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for DataSection {
|
||||
type Error = Error;
|
||||
|
||||
fn serialize<W: io::Write>(self, writer: &mut W) -> Result<(), Self::Error> {
|
||||
let mut counted_writer = CountedWriter::new(writer);
|
||||
let test = vec![0u8; 12];
|
||||
counted_writer.write(&test[..])?;
|
||||
counted_writer.done()?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
|
Reference in New Issue
Block a user