Merge ssz little endian branch

This commit is contained in:
Kirk Baird
2019-03-26 15:44:01 +11:00
45 changed files with 14240 additions and 266 deletions

View File

@@ -38,6 +38,24 @@ impl<'de> Visitor<'de> for PrefixedHexVisitor {
}
}
pub struct HexVisitor;
impl<'de> Visitor<'de> for HexVisitor {
type Value = Vec<u8>;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("a hex string (irrelevant of prefix)")
}
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
Ok(hex::decode(value.trim_start_matches("0x"))
.map_err(|e| de::Error::custom(format!("invalid hex ({:?})", e)))?)
}
}
#[cfg(test)]
mod test {
use super::*;