message: Add Binary <-> HexBinary conversion
diff: @@ -4,7 +4,7 @@ use std::ops::Deref;
  use schemars::JsonSchema;
  use serde::{de, ser, Deserialize, Deserializer, Serialize};
  -use crate::{StdError, StdResult};
  +use crate::{Binary, StdError, StdResult};
  /// This is a wrapper around Vec<u8> to add hex de/serialization
  /// with serde. It also adds some helper methods to help encode inline.
  @@ -125,6 +125,18 @@ impl From<HexBinary> for Vec<u8> {
  }
  }
  +impl From<Binary> for HexBinary {
  + fn from(original: Binary) -> Self {
  + Self(original.into())
  + }
  +}
  +
  +impl From<HexBinary> for Binary {
  + fn from(original: HexBinary) -> Binary {
  + Binary::from(original.0)
  + }
  +}
  +
  /// Implement `HexBinary == std::vec::Vec<u8>`
  impl PartialEq<Vec<u8>> for HexBinary {
  fn eq(&self, rhs: &Vec<u8>) -> bool {
  @@ -451,6 +463,32 @@ mod tests {
  assert_eq!(vec.as_ptr(), original_ptr, "vector must not be copied");
  }
  + #[test]
  + fn from_binary_works() {
  + let original = Binary::from([0u8, 187, 61, 11, 250, 0]);
  + let original_ptr = original.as_ptr();
  + let binary: HexBinary = original.into();
  + assert_eq!(binary.as_slice(), [0u8, 187, 61, 11, 250, 0]);
  + assert_eq!(binary.0.as_ptr(), original_ptr, "vector must not be copied");
  + }
  +
  + #[test]
  + fn into_binary_works() {
  + // Into<Binary> for HexBinary
  + let original = HexBinary(vec![0u8, 187, 61, 11, 250, 0]);
  + let original_ptr = original.0.as_ptr();
  + let bin: Binary = original.into();
  + assert_eq!(bin.as_slice(), [0u8, 187, 61, 11, 250, 0]);
  + assert_eq!(bin.as_ptr(), original_ptr, "vector must not be copied");
  +
  + // From<HexBinary> for Binary
  + let original = HexBinary(vec![7u8, 35, 49, 101, 0, 255]);
  + let original_ptr = original.0.as_ptr();
  + let bin = Binary::from(original);
  + assert_eq!(bin.as_slice(), [7u8, 35, 49, 101, 0, 255]);
  + assert_eq!(bin.as_ptr(), original_ptr, "vector must not be copied");
  + }
  +
  #[test]
  fn serialization_works() {
  let binary = HexBinary(vec![0u8, 187, 61, 11, 250, 0]);
  