message: [secure-storage] Add bytes <-> base64 string adapter
diff: @@ -29,5 +29,24 @@ pub use crate::{
  vault::VaultStorage,
  };
  +// Some common serializations for interacting with bytes these must be manually added to types via:
  +// #[serde(serialize_with = "to_base64", deserialize_with = "from_base64")]
  +// some_value: Vec<u8>
  +
  +pub fn to_base64<S>(bytes: &[u8], serializer: S) -> Result<S::Ok, S::Error>
  +where
  + S: serde::Serializer,
  +{
  + serializer.serialize_str(&base64::encode(bytes))
  +}
  +
  +pub fn from_base64<'de, D>(deserializer: D) -> Result<Vec<u8>, D::Error>
  +where
  + D: serde::Deserializer<'de>,
  +{
  + let s: String = serde::Deserialize::deserialize(deserializer)?;
  + base64::decode(s).map_err(serde::de::Error::custom)
  +}
  +
  #[cfg(test)]
  mod tests;
  