pub fn deserialize<'de, D>(deserializer: D) -> Result<Vec<u8>, D::Error>
where
	D: Deserializer<'de>,
{
	struct Visitor;

	impl<'b> de::Visitor<'b> for Visitor {
		type Value = Vec<u8>;

		fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
			write!(formatter, "a (both 0x-prefixed or not) hex string")
		}

		fn visit_str<E: de::Error>(self, v: &str) -> Result<Self::Value, E> {
			from_hex(v).map_err(E::custom)
		}

		fn visit_string<E: de::Error>(self, v: String) -> Result<Self::Value, E> {
			self.visit_str(&v)
		}
	}

	deserializer.deserialize_str(Visitor)
}
/// Deserialize into vector of bytes.  This will allocate an O(n) intermediate
/// string.
Deserialize into vector of bytes.  This will allocate an O(n) intermediate
string.
Deserialize into vector of bytes . This will allocate an O ( n ) intermediate string .
pub fn deserialize<'de, D>(deserializer: D) -> Result<Vec<u8>, D::Error>
where
	D: Deserializer<'de>,
{
	struct Visitor;
	impl<'b> de::Visitor<'b> for Visitor {
		type Value = Vec<u8>;
		fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
			write!(formatter, "a (both 0x-prefixed or not) hex string")
		}
		fn visit_str<E: de::Error>(self, v: &str) -> Result<Self::Value, E> {
			from_hex(v).map_err(E::custom)
		}
		fn visit_string<E: de::Error>(self, v: String) -> Result<Self::Value, E> {
			self.visit_str(&v)
		}
	}
	deserializer.deserialize_str(Visitor)
}
pub fn deserialize < ' de , D > ( deserializer : D ) -> Result < Vec < u8 > , D :: Error > where D : Deserializer < ' de > , { struct Visitor ; impl < ' b > de :: Visitor < ' b > for Visitor { type Value = Vec < u8 > ; fn expecting ( & self , formatter : & mut fmt :: Formatter ) -> fmt :: Result { write ! ( formatter " " ) } fn visit_str < E : de :: Error > ( self , v : & str ) -> Result < Self :: Value , E > { from_hex ( v ) . map_err ( E :: custom ) } fn visit_string < E : de :: Error > ( self , v : String ) -> Result < Self :: Value , E > { self . visit_str ( & v ) } } deserializer . deserialize_str ( Visitor ) }
Deserialize into vector of bytes.
Deserialize into vector of bytes .
deserializer
D
deserializer
D