Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce SigmaByteWrite trait and the writer impl;
- Loading branch information
Showing
23 changed files
with
182 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use super::sigma_byte_writer::SigmaByteWrite; | ||
use crate::ast::ConstantPlaceholder; | ||
use crate::serialization::{ | ||
sigma_byte_reader::SigmaByteRead, SerializationError, SigmaSerializable, | ||
}; | ||
|
||
use std::io; | ||
|
||
impl SigmaSerializable for ConstantPlaceholder { | ||
fn sigma_serialize<W: SigmaByteWrite>(&self, w: &mut W) -> Result<(), io::Error> { | ||
w.put_u32(self.id) | ||
} | ||
|
||
fn sigma_parse<R: SigmaByteRead>(r: &mut R) -> Result<Self, SerializationError> { | ||
let id = r.get_u32()?; | ||
if let Some(c) = r.constant_store().get(id) { | ||
Ok(ConstantPlaceholder { | ||
id, | ||
tpe: c.tpe.clone(), | ||
}) | ||
} else { | ||
Err(SerializationError::ConstantForPlaceholderNotFound(id)) | ||
} | ||
} | ||
} | ||
|
||
// #[cfg(test)] | ||
// mod tests { | ||
// use super::*; | ||
// use crate::serialization::sigma_serialize_roundtrip; | ||
// use proptest::prelude::*; | ||
|
||
// proptest! { | ||
|
||
// #[test] | ||
// fn ser_roundtrip(v in any::<ConstantPlaceholder>()) { | ||
// prop_assert_eq![sigma_serialize_roundtrip(&v), v]; | ||
// } | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.