1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#![forbid(unsafe_code)]
mod crypto_kv_storage;
mod crypto_storage;
mod error;
mod github;
mod in_memory;
mod kv_storage;
mod namespaced;
mod on_disk;
mod policy;
mod storage;
mod vault;
pub use crate::{
crypto_kv_storage::CryptoKVStorage,
crypto_storage::{CryptoStorage, PublicKeyResponse},
error::Error,
github::GitHubStorage,
in_memory::InMemoryStorage,
kv_storage::{GetResponse, KVStorage},
namespaced::Namespaced,
on_disk::OnDiskStorage,
policy::{Capability, Identity, Permission, Policy},
storage::Storage,
vault::VaultStorage,
};
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;