blob: 0375c774ef436cd4a9b0507d15c2ec08395bc02d (
plain)
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
|
use sequoia_openpgp as openpgp;
use openpgp::serialize::Serialize;
use super::{
AutocryptHeader,
Error,
Result,
};
impl Serialize for AutocryptHeader {
fn serialize(&self, o: &mut dyn std::io::Write) -> Result<()> {
if self.key.is_none() {
return Err(Error::InvalidOperation("No key".into()).into());
}
for attr in self.attributes.iter() {
write!(o, "{}={}; ", attr.key, attr.value)?;
}
let mut buf = Vec::new();
self.key.as_ref().unwrap().serialize(&mut buf)?;
write!(o, "keydata={} ", base64::encode(&buf))?;
Ok(())
}
}
|