From d9acee5a7260bf2e63ea20ddbf494f0e4d4a59b6 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Thu, 12 Oct 2023 03:49:08 +1100 Subject: [PATCH] Delete unused ssz_types file (#4824) --- .../src/serde_utils/list_of_hex_fixed_vec.rs | 77 ------------------- 1 file changed, 77 deletions(-) delete mode 100644 consensus/ssz_types/src/serde_utils/list_of_hex_fixed_vec.rs diff --git a/consensus/ssz_types/src/serde_utils/list_of_hex_fixed_vec.rs b/consensus/ssz_types/src/serde_utils/list_of_hex_fixed_vec.rs deleted file mode 100644 index b93c869067c..00000000000 --- a/consensus/ssz_types/src/serde_utils/list_of_hex_fixed_vec.rs +++ /dev/null @@ -1,77 +0,0 @@ -//! Serialize `VariableList, N>` as list of 0x-prefixed hex string. -use crate::{FixedVector, VariableList}; -use serde::{ser::SerializeSeq, Deserialize, Deserializer, Serialize, Serializer}; -use std::marker::PhantomData; -use typenum::Unsigned; - -#[derive(Deserialize)] -#[serde(transparent)] -pub struct WrappedListOwned( - #[serde(with = "crate::serde_utils::hex_fixed_vec")] FixedVector, -); - -#[derive(Serialize)] -#[serde(transparent)] -pub struct WrappedListRef<'a, N: Unsigned>( - #[serde(with = "crate::serde_utils::hex_fixed_vec")] &'a FixedVector, -); - -pub fn serialize( - list: &VariableList, N>, - serializer: S, -) -> Result -where - S: Serializer, - M: Unsigned, - N: Unsigned, -{ - let mut seq = serializer.serialize_seq(Some(list.len()))?; - for bytes in list { - seq.serialize_element(&WrappedListRef(bytes))?; - } - seq.end() -} - -#[derive(Default)] -pub struct Visitor { - _phantom_m: PhantomData, - _phantom_n: PhantomData, -} - -impl<'a, M, N> serde::de::Visitor<'a> for Visitor -where - M: Unsigned, - N: Unsigned, -{ - type Value = VariableList, N>; - - fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { - write!(formatter, "a list of 0x-prefixed hex bytes") - } - - fn visit_seq(self, mut seq: A) -> Result - where - A: serde::de::SeqAccess<'a>, - { - let mut list: VariableList, N> = <_>::default(); - - while let Some(val) = seq.next_element::>()? { - list.push(val.0).map_err(|e| { - serde::de::Error::custom(format!("failed to push value to list: {:?}.", e)) - })?; - } - - Ok(list) - } -} - -pub fn deserialize<'de, D, M, N>( - deserializer: D, -) -> Result, N>, D::Error> -where - D: Deserializer<'de>, - M: Unsigned, - N: Unsigned, -{ - deserializer.deserialize_seq(Visitor::default()) -}