sare_core/format/
mod.rs

1use secrecy::{SecretString, SecretVec};
2
3pub mod certificate;
4pub mod encryption;
5pub mod error;
6pub mod header;
7pub mod keys;
8pub mod signature;
9
10use error::*;
11
12pub trait EncodablePublic {
13    fn encode_bson(&self) -> Vec<u8>;
14    fn decode_bson(bson_data: &[u8]) -> Result<Self, FormatError>
15    where
16        Self: Sized;
17    fn encode_pem(&self) -> String;
18    fn decode_pem(pem_data: &str) -> Result<Self, FormatError>
19    where
20        Self: Sized;
21}
22
23pub trait EncodableSecret {
24    fn encode_bson(&self) -> SecretVec<u8>;
25    fn decode_bson(bson_data: &SecretVec<u8>) -> Result<Self, FormatError>
26    where
27        Self: Sized;
28    fn encode_pem(&self) -> SecretString;
29    fn decode_pem(pem_data: SecretString) -> Result<Self, FormatError>
30    where
31        Self: Sized;
32}