@@ -16,18 +16,18 @@ pub struct Metadata {
|
||||
}
|
||||
|
||||
pub fn wrap<'a>(domain: &'a str, entity: &'a str, content: &'a [u8]) -> Vec<u8> {
|
||||
let output = serde_json::to_vec(&Envelope {
|
||||
|
||||
|
||||
serde_json::to_vec(&Envelope {
|
||||
content: general_purpose::URL_SAFE_NO_PAD.encode(content),
|
||||
metadata: Metadata {
|
||||
domain: domain.to_string(),
|
||||
entity: entity.to_string(),
|
||||
},
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
output
|
||||
.unwrap()
|
||||
}
|
||||
pub fn unwrap<'a>(message: &'a [u8]) -> Result<(Vec<u8>, Metadata), EnvelopeError> {
|
||||
pub fn unwrap(message: &[u8]) -> Result<(Vec<u8>, Metadata), EnvelopeError> {
|
||||
let envelope: Envelope = serde_json::from_slice(message).map_err(EnvelopeError::JsonError)?;
|
||||
|
||||
Ok((
|
||||
|
Reference in New Issue
Block a user