diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2018-08-24 10:33:28 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2018-08-24 10:46:54 +0200 |
commit | 576cffeac8bd9ffd4ac7b1c4a9b5c8714a227b7b (patch) | |
tree | bd7220edd6f8992a374e3bcd461e7aa107c3e793 /openpgp/src | |
parent | 4a89c04d9b93a9f3e6140fead7955a53ade151f1 (diff) |
openpgp: Make struct Literal opaque, add getters and setters.
- See #57.
Diffstat (limited to 'openpgp/src')
-rw-r--r-- | openpgp/src/armor.rs | 2 | ||||
-rw-r--r-- | openpgp/src/constants.rs | 7 | ||||
-rw-r--r-- | openpgp/src/lib.rs | 8 | ||||
-rw-r--r-- | openpgp/src/literal.rs | 88 | ||||
-rw-r--r-- | openpgp/src/message/mod.rs | 55 | ||||
-rw-r--r-- | openpgp/src/packet_pile.rs | 47 | ||||
-rw-r--r-- | openpgp/src/serialize/mod.rs | 47 | ||||
-rw-r--r-- | openpgp/src/serialize/stream.rs | 34 |
8 files changed, 168 insertions, 120 deletions
diff --git a/openpgp/src/armor.rs b/openpgp/src/armor.rs index 6a09cc2b..4a82355b 100644 --- a/openpgp/src/armor.rs +++ b/openpgp/src/armor.rs @@ -369,7 +369,7 @@ impl<'a> Reader<'a> { /// reader.read_to_end(&mut buf)?; /// /// let message = Message::from_bytes(&buf)?; - /// assert_eq!(message.body().unwrap().common.body.as_ref().unwrap(), + /// assert_eq!(message.body().unwrap().body().unwrap(), /// b"Hello world!"); /// # Ok(()) /// # } diff --git a/openpgp/src/constants.rs b/openpgp/src/constants.rs index 6cdc2bbd..82254536 100644 --- a/openpgp/src/constants.rs +++ b/openpgp/src/constants.rs @@ -772,12 +772,19 @@ impl Arbitrary for ReasonForRevocation { #[derive(Clone, Copy, Hash, PartialEq, Eq, Debug, PartialOrd, Ord)] pub enum DataFormat { /// Binary data. + /// + /// This is a hint that the content is probably binary data. Binary, /// Text data. + /// + /// This is a hint that the content is probably text; the encoding + /// is not specified. Text, /// Text data, probably valid UTF-8. + /// + /// This is a hint that the content is probably UTF-8 encoded. Unicode, /// MIME message. diff --git a/openpgp/src/lib.rs b/openpgp/src/lib.rs index 97000ebd..f489ec3b 100644 --- a/openpgp/src/lib.rs +++ b/openpgp/src/lib.rs @@ -333,18 +333,18 @@ pub struct UserAttribute { #[derive(PartialEq, Clone)] pub struct Literal { /// CTB packet header fields. - pub common: packet::Common, + common: packet::Common, /// A one-octet field that describes how the data is formatted. - pub format: DataFormat, + format: DataFormat, /// filename is a string, but strings in Rust are valid UTF-8. /// There is no guarantee, however, that the filename is valid /// UTF-8. Thus, we leave filename as a byte array. It can be /// converted to a string using String::from_utf8() or /// String::from_utf8_lossy(). - pub filename: Option<Vec<u8>>, + filename: Option<Vec<u8>>, /// A four-octet number that indicates a date associated with the /// literal data. - pub date: time::Tm, + date: time::Tm, } /// Holds a compressed data packet. diff --git a/openpgp/src/literal.rs b/openpgp/src/literal.rs index 70581375..a0597f8f 100644 --- a/openpgp/src/literal.rs +++ b/openpgp/src/literal.rs @@ -4,8 +4,10 @@ use time; use constants::DataFormat; use conversions::Time; +use Error; use Literal; use Packet; +use Result; impl fmt::Debug for Literal { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -49,83 +51,67 @@ impl Literal { } } + /// Gets the Literal packet's body. + pub fn body(&self) -> Option<&[u8]> { + self.common.body.as_ref().map(|b| b.as_slice()) + } + /// Sets the Literal packet's body to the provided byte string. - pub fn body(mut self, data: Vec<u8>) -> Literal { + pub fn set_body(&mut self, data: Vec<u8>) { self.common.body = Some(data); - self } - /// Sets the Literal packet's content disposition to text. - /// - /// This is a hint that the content is probably text; the encoding - /// is not specified. - pub fn text(mut self) -> Literal { - self.format = DataFormat::Text; - self + /// Gets the Literal packet's content disposition. + pub fn format(&mut self) -> DataFormat { + self.format } - /// Sets the Literal packet's content disposition to UTF-8. - /// - /// This is a hint that the content is probably UTF-8 encoded. - pub fn utf8(mut self) -> Literal { - self.format = DataFormat::Unicode; - self + /// Sets the Literal packet's content disposition. + pub fn set_format(&mut self, format: DataFormat) { + self.format = format; } - /// Sets the Literal packet's content disposition to binary. - /// - /// This is a hint that the content is probably binary data. - pub fn binary(mut self) -> Literal { - self.format = DataFormat::Binary; - self - } - - /// Sets the Literal packet's content disposition to MIME. - /// - /// This is specified in RFC 4880bis, which has not yet been - /// standardized. - pub fn mime(mut self) -> Literal { - self.format = DataFormat::MIME; - self + /// Gets the literal packet's filename. + pub fn filename(&self) -> Option<&[u8]> { + self.filename.as_ref().map(|b| b.as_slice()) } /// Sets the literal packet's filename field from a byte sequence. /// - /// The standard does not specify the encoding. - /// - /// This function panics, if the filename is longer than 255 - /// bytes, which is the limit imposed by RFC 4880. - pub fn filename_from_bytes(mut self, filename: &[u8]) -> Literal { + /// The standard does not specify the encoding. Filenames must + /// not be longer than 255 bytes. + pub fn set_filename_from_bytes(&mut self, filename: &[u8]) -> Result<()> { if filename.len() > 255 { - panic!("Filename too long."); + return + Err(Error::InvalidArgument("filename too long".into()).into()); } self.filename = Some(filename.to_vec()); - self + Ok(()) } /// Sets the literal packet's filename field from a UTF-8 encoded /// string. /// /// This is a convenience function, since the field is actually a - /// raw byte string. - /// - /// This function panics, if the filename is longer than 255 - /// bytes, which is the limit imposed by RFC 4880. - pub fn filename(mut self, filename: &str) -> Literal { + /// raw byte string. Filenames must not be longer than 255 bytes. + pub fn set_filename(&mut self, filename: &str) -> Result<()> { + let filename = filename.as_bytes().to_vec(); if filename.len() > 255 { - panic!("Filename too long."); + return + Err(Error::InvalidArgument("filename too long".into()).into()); } - self.filename = Some(filename.as_bytes().to_vec()); - self + self.filename = Some(filename); + Ok(()) } - /// Sets the literal packet's date field using a Unix timestamp. - /// - /// A Unix timestamp is the number of seconds since the Unix - /// epoch. - pub fn date(mut self, timestamp: time::Tm) -> Literal { + /// Gets the literal packet's date field. + pub fn date(&self) -> time::Tm { + self.date + } + + /// Sets the literal packet's date field. + pub fn set_date(&mut self, timestamp: time::Tm) { self.date = timestamp; - self } /// Convert the `Literal` struct to a `Packet`. diff --git a/openpgp/src/message/mod.rs b/openpgp/src/message/mod.rs index 9bff4452..16c1b803 100644 --- a/openpgp/src/message/mod.rs +++ b/openpgp/src/message/mod.rs @@ -645,7 +645,9 @@ mod tests { // 0: Literal // => good. let mut packets = Vec::new(); - packets.push(Literal::new(Text).body(b"data".to_vec()).to_packet()); + let mut lit = Literal::new(Text); + lit.set_body(b"data".to_vec()); + packets.push(lit.to_packet()); let message = Message::from_packets(packets); assert!(message.is_ok(), "{:?}", message); @@ -653,13 +655,16 @@ mod tests { #[test] fn compressed_part() { + let mut lit = Literal::new(Text); + lit.set_body(b"data".to_vec()); + // 0: CompressedData // 0: Literal // => good. let mut packets = Vec::new(); packets.push( CompressedData::new(CompressionAlgorithm::Uncompressed) - .push(Literal::new(Text).body(b"inner".to_vec()).to_packet()) + .push(lit.clone().to_packet()) .to_packet()); let message = Message::from_packets(packets); @@ -672,8 +677,8 @@ mod tests { let mut packets = Vec::new(); packets.push( CompressedData::new(CompressionAlgorithm::Uncompressed) - .push(Literal::new(Text).body(b"inner one".to_vec()).to_packet()) - .push(Literal::new(Text).body(b"inner two".to_vec()).to_packet()) + .push(lit.clone().to_packet()) + .push(lit.clone().to_packet()) .to_packet()); let message = Message::from_packets(packets); @@ -686,9 +691,9 @@ mod tests { let mut packets = Vec::new(); packets.push( CompressedData::new(CompressionAlgorithm::Uncompressed) - .push(Literal::new(Text).body(b"inner".to_vec()).to_packet()) + .push(lit.clone().to_packet()) .to_packet()); - packets.push(Literal::new(Text).body(b"outer".to_vec()).to_packet()); + packets.push(lit.clone().to_packet()); let message = Message::from_packets(packets); assert!(message.is_err(), "{:?}", message); @@ -701,7 +706,7 @@ mod tests { packets.push( CompressedData::new(CompressionAlgorithm::Uncompressed) .push(CompressedData::new(CompressionAlgorithm::Uncompressed) - .push(Literal::new(Text).body(b"inner".to_vec()) + .push(lit.clone() .to_packet()) .to_packet()) .to_packet()); @@ -712,6 +717,9 @@ mod tests { #[test] fn one_pass_sig_part() { + let mut lit = Literal::new(Text); + lit.set_body(b"data".to_vec()); + // 0: OnePassSig // => bad. let mut packets : Vec<Packet> = Vec::new(); @@ -725,7 +733,7 @@ mod tests { // => bad. let mut packets : Vec<Packet> = Vec::new(); packets.push(OnePassSig::new(SignatureType::Binary).to_packet()); - packets.push(Literal::new(Text).body(b"inner".to_vec()).to_packet()); + packets.push(lit.clone().to_packet()); let message = Message::from_packets(packets); assert!(message.is_err(), "{:?}", message); @@ -736,7 +744,7 @@ mod tests { // => good. let mut packets : Vec<Packet> = Vec::new(); packets.push(OnePassSig::new(SignatureType::Binary).to_packet()); - packets.push(Literal::new(Text).body(b"inner".to_vec()).to_packet()); + packets.push(lit.clone().to_packet()); packets.push(Signature::new(SignatureType::Binary).to_packet()); let message = Message::from_packets(packets); @@ -749,7 +757,7 @@ mod tests { // => bad. let mut packets : Vec<Packet> = Vec::new(); packets.push(OnePassSig::new(SignatureType::Binary).to_packet()); - packets.push(Literal::new(Text).body(b"inner".to_vec()).to_packet()); + packets.push(lit.clone().to_packet()); packets.push(Signature::new(SignatureType::Binary).to_packet()); packets.push(Signature::new(SignatureType::Binary).to_packet()); @@ -765,7 +773,7 @@ mod tests { let mut packets : Vec<Packet> = Vec::new(); packets.push(OnePassSig::new(SignatureType::Binary).to_packet()); packets.push(OnePassSig::new(SignatureType::Binary).to_packet()); - packets.push(Literal::new(Text).body(b"inner".to_vec()).to_packet()); + packets.push(lit.clone().to_packet()); packets.push(Signature::new(SignatureType::Binary).to_packet()); packets.push(Signature::new(SignatureType::Binary).to_packet()); @@ -782,8 +790,8 @@ mod tests { let mut packets : Vec<Packet> = Vec::new(); packets.push(OnePassSig::new(SignatureType::Binary).to_packet()); packets.push(OnePassSig::new(SignatureType::Binary).to_packet()); - packets.push(Literal::new(Text).body(b"inner".to_vec()).to_packet()); - packets.push(Literal::new(Text).body(b"inner".to_vec()).to_packet()); + packets.push(lit.clone().to_packet()); + packets.push(lit.clone().to_packet()); packets.push(Signature::new(SignatureType::Binary).to_packet()); packets.push(Signature::new(SignatureType::Binary).to_packet()); @@ -802,7 +810,7 @@ mod tests { packets.push(OnePassSig::new(SignatureType::Binary).to_packet()); packets.push( CompressedData::new(CompressionAlgorithm::Uncompressed) - .push(Literal::new(Text).body(b"inner".to_vec()).to_packet()) + .push(lit.clone().to_packet()) .to_packet()); packets.push(Signature::new(SignatureType::Binary).to_packet()); packets.push(Signature::new(SignatureType::Binary).to_packet()); @@ -813,6 +821,9 @@ mod tests { #[test] fn signature_part() { + let mut lit = Literal::new(Text); + lit.set_body(b"data".to_vec()); + // 0: Signature // => bad. let mut packets : Vec<Packet> = Vec::new(); @@ -826,7 +837,7 @@ mod tests { // => good. let mut packets : Vec<Packet> = Vec::new(); packets.push(Signature::new(SignatureType::Binary).to_packet()); - packets.push(Literal::new(Text).body(b"inner".to_vec()).to_packet()); + packets.push(lit.clone().to_packet()); let message = Message::from_packets(packets); assert!(message.is_ok(), "{:?}", message); @@ -838,7 +849,7 @@ mod tests { let mut packets : Vec<Packet> = Vec::new(); packets.push(Signature::new(SignatureType::Binary).to_packet()); packets.push(Signature::new(SignatureType::Binary).to_packet()); - packets.push(Literal::new(Text).body(b"inner".to_vec()).to_packet()); + packets.push(lit.clone().to_packet()); let message = Message::from_packets(packets); assert!(message.is_ok(), "{:?}", message); @@ -852,6 +863,9 @@ mod tests { // internal iterfaces to progressively build up more // complicated messages. + let mut lit = Literal::new(Text); + lit.set_body(b"data".to_vec()); + // 0: SK-ESK // => bad. let mut packets : Vec<Packet> = Vec::new(); @@ -865,7 +879,7 @@ mod tests { // 0: SK-ESK // 1: Literal // => bad. - packets.push(Literal::new(Text).body(b"inner".to_vec()).to_packet()); + packets.push(lit.clone().to_packet()); assert!(packets.iter().map(|p| p.tag()).collect::<Vec<Tag>>() == [ Tag::SKESK, Tag::Literal ]); @@ -884,7 +898,7 @@ mod tests { }; seip.common.children = Some(Container::new()); seip.common.children.as_mut().unwrap().push( - Literal::new(Text).body(b"inner".to_vec()).to_packet()); + lit.clone().to_packet()); seip.common.children.as_mut().unwrap().push( MDC::for_hash(Default::default()).to_packet()); packets[1] = Packet::SEIP(seip); @@ -949,7 +963,7 @@ mod tests { // 1: MDC // 3: Literal // => bad. - packets[3] = Literal::new(Text).body(b"inner".to_vec()).to_packet(); + packets[3] = lit.clone().to_packet(); assert!(packets.iter().map(|p| p.tag()).collect::<Vec<Tag>>() == [ Tag::SKESK, Tag::SKESK, Tag::SEIP, Tag::Literal ]); @@ -965,8 +979,7 @@ mod tests { // 2: Literal // => bad. packets.remove(3); - packets[2].children.as_mut().unwrap().push( - Literal::new(Text).body(b"inner two".to_vec()).to_packet()); + packets[2].children.as_mut().unwrap().push(lit.clone().to_packet()); assert!(packets.iter().map(|p| p.tag()).collect::<Vec<Tag>>() == [ Tag::SKESK, Tag::SKESK, Tag::SEIP ]); diff --git a/openpgp/src/packet_pile.rs b/openpgp/src/packet_pile.rs index aa42aac9..342d5aba 100644 --- a/openpgp/src/packet_pile.rs +++ b/openpgp/src/packet_pile.rs @@ -165,21 +165,22 @@ impl PacketPile { /// # fn main() { f().unwrap(); } /// # fn f() -> Result<()> { /// // A compressed data packet that contains a literal data packet. + /// let mut literal = Literal::new(DataFormat::Text); + /// literal.set_body(b"old".to_vec()); /// let mut pile = PacketPile::from_packet( /// CompressedData::new(CompressionAlgorithm::Uncompressed) - /// .push(Literal::new(DataFormat::Text).body(b"old".to_vec()) - /// .to_packet()) + /// .push(literal.to_packet()) /// .to_packet()); /// /// // Replace the literal data packet. + /// let mut literal = Literal::new(DataFormat::Text); + /// literal.set_body(b"new".to_vec()); /// pile.replace( /// &[ 0, 0 ], 1, - /// [ Literal::new(DataFormat::Text).body(b"new".to_vec()).to_packet() ] - /// .to_vec()) + /// [ literal.to_packet() ].to_vec()) /// .unwrap(); /// # if let Some(Packet::Literal(lit)) = pile.path_ref(&[0, 0]) { - /// # assert_eq!(lit.common.body, Some(b"new".to_vec()), - /// # "{:#?}", lit); + /// # assert_eq!(lit.body(), Some(&b"new"[..]), "{:#?}", lit); /// # } else { /// # panic!("Unexpected packet!"); /// # } @@ -650,7 +651,9 @@ mod message_test { let mut cd = CompressedData::new(CompressionAlgorithm::Uncompressed); for t in text.iter() { - cd = cd.push(Literal::new(Text).body(t.to_vec()).to_packet()) + let mut lit = Literal::new(Text); + lit.set_body(t.to_vec()); + cd = cd.push(lit.to_packet()) } let mut seip = SEIP { @@ -715,8 +718,12 @@ mod message_test { // 0: Literal("one") // => // 0: Literal("two") + let mut one = Literal::new(Text); + one.set_body(b"one".to_vec()); + let mut two = Literal::new(Text); + two.set_body(b"two".to_vec()); let mut packets : Vec<Packet> = Vec::new(); - packets.push(Literal::new(Text).body(b"one".to_vec()).to_packet()); + packets.push(one.to_packet()); assert!(packets.iter().map(|p| p.tag()).collect::<Vec<Tag>>() == [ Tag::Literal ]); @@ -724,7 +731,7 @@ mod message_test { let mut pile = PacketPile::from_packets(packets.clone()); pile.replace( &[ 0 ], 1, - [ Literal::new(Text).body(b"two".to_vec()).to_packet() + [ two.to_packet() ].to_vec()).unwrap(); let children = pile.into_children().collect::<Vec<Packet>>(); @@ -745,7 +752,9 @@ mod message_test { let mut packets : Vec<Packet> = Vec::new(); for text in initial.iter() { - packets.push(Literal::new(Text).body(text.to_vec()).to_packet()) + let mut lit = Literal::new(Text); + lit.set_body(text.to_vec()); + packets.push(lit.to_packet()) } for start in 0..initial.len() + 1 { @@ -755,8 +764,9 @@ mod message_test { let mut replacement : Vec<Packet> = Vec::new(); for &text in inserted[0..insert].iter() { - replacement.push( - Literal::new(Text).body(text.to_vec()).to_packet()) + let mut lit = Literal::new(Text); + lit.set_body(text.to_vec()); + replacement.push(lit.to_packet()); } pile.replace(&[ start ], delete, replacement).unwrap(); @@ -795,7 +805,9 @@ mod message_test { let mut cd = CompressedData::new(CompressionAlgorithm::Uncompressed); for l in initial.iter() { - cd = cd.push(Literal::new(Text).body(l.to_vec()).to_packet()) + let mut lit = Literal::new(Text); + lit.set_body(l.to_vec()); + cd = cd.push(lit.to_packet()); } for start in 0..initial.len() + 1 { @@ -806,8 +818,9 @@ mod message_test { let mut replacement : Vec<Packet> = Vec::new(); for &text in inserted[0..insert].iter() { - replacement.push( - Literal::new(Text).body(text.to_vec()).to_packet()) + let mut lit = Literal::new(Text); + lit.set_body(text.to_vec()); + replacement.push(lit.to_packet()); } pile.replace(&[ 0, start ], delete, replacement).unwrap(); @@ -839,8 +852,10 @@ mod message_test { } // Make sure out-of-range accesses error out. + let mut one = Literal::new(Text); + one.set_body(b"one".to_vec()); let mut packets : Vec<Packet> = Vec::new(); - packets.push(Literal::new(Text).body(b"one".to_vec()).to_packet()); + packets.push(one.to_packet()); let mut pile = PacketPile::from_packets(packets.clone()); assert!(pile.replace(&[ 1 ], 0, Vec::new()).is_ok()); diff --git a/openpgp/src/serialize/mod.rs b/openpgp/src/serialize/mod.rs index fac83400..6d22cb4c 100644 --- a/openpgp/src/serialize/mod.rs +++ b/openpgp/src/serialize/mod.rs @@ -1323,13 +1323,26 @@ mod serialize_test { // 1: Literal(Literal { body: "one (3 bytes)" }) // 2: Literal(Literal { body: "two (3 bytes)" }) // 2: Literal(Literal { body: "three (5 bytes)" }) + let mut one = Literal::new(T); + one.set_body(b"one".to_vec()); + let mut two = Literal::new(T); + two.set_body(b"two".to_vec()); + let mut three = Literal::new(T); + three.set_body(b"three".to_vec()); + let mut four = Literal::new(T); + four.set_body(b"four".to_vec()); + let mut five = Literal::new(T); + five.set_body(b"five".to_vec()); + let mut six = Literal::new(T); + six.set_body(b"six".to_vec()); + let mut top_level = Vec::new(); top_level.push( CompressedData::new(CompressionAlgorithm::Uncompressed) - .push(Literal::new(T).body(b"one".to_vec()).to_packet()) - .push(Literal::new(T).body(b"two".to_vec()).to_packet()) + .push(one.clone().to_packet()) + .push(two.clone().to_packet()) .to_packet()); - top_level.push(Literal::new(T).body(b"three".to_vec()).to_packet()); + top_level.push(three.clone().to_packet()); messages.push(top_level); // 1: CompressedData(CompressedData { algo: 0 }) @@ -1343,12 +1356,12 @@ mod serialize_test { top_level.push( CompressedData::new(CompressionAlgorithm::Uncompressed) .push(CompressedData::new(CompressionAlgorithm::Uncompressed) - .push(Literal::new(T).body(b"one".to_vec()).to_packet()) - .push(Literal::new(T).body(b"two".to_vec()).to_packet()) + .push(one.clone().to_packet()) + .push(two.clone().to_packet()) .to_packet()) .push(CompressedData::new(CompressionAlgorithm::Uncompressed) - .push(Literal::new(T).body(b"three".to_vec()).to_packet()) - .push(Literal::new(T).body(b"four".to_vec()).to_packet()) + .push(three.clone().to_packet()) + .push(four.clone().to_packet()) .to_packet()) .to_packet()); messages.push(top_level); @@ -1369,16 +1382,16 @@ mod serialize_test { .push(CompressedData::new(CompressionAlgorithm::Uncompressed) .push(CompressedData::new(CompressionAlgorithm::Uncompressed) .push(CompressedData::new(CompressionAlgorithm::Uncompressed) - .push(Literal::new(T).body(b"one".to_vec()).to_packet()) - .push(Literal::new(T).body(b"two".to_vec()).to_packet()) + .push(one.clone().to_packet()) + .push(two.clone().to_packet()) .to_packet()) .to_packet()) .to_packet()) .push(CompressedData::new(CompressionAlgorithm::Uncompressed) .push(CompressedData::new(CompressionAlgorithm::Uncompressed) - .push(Literal::new(T).body(b"three".to_vec()).to_packet()) + .push(three.clone().to_packet()) .to_packet()) - .push(Literal::new(T).body(b"four".to_vec()).to_packet()) + .push(four.clone().to_packet()) .to_packet()) .to_packet()); messages.push(top_level); @@ -1394,17 +1407,17 @@ mod serialize_test { let mut top_level = Vec::new(); top_level.push( CompressedData::new(CompressionAlgorithm::Uncompressed) - .push(Literal::new(T).body(b"one".to_vec()).to_packet()) - .push(Literal::new(T).body(b"two".to_vec()).to_packet()) + .push(one.clone().to_packet()) + .push(two.clone().to_packet()) .to_packet()); top_level.push( - Literal::new(T).body(b"three".to_vec()).to_packet()); + three.clone().to_packet()); top_level.push( - Literal::new(T).body(b"four".to_vec()).to_packet()); + four.clone().to_packet()); top_level.push( CompressedData::new(CompressionAlgorithm::Uncompressed) - .push(Literal::new(T).body(b"five".to_vec()).to_packet()) - .push(Literal::new(T).body(b"six".to_vec()).to_packet()) + .push(five.to_packet()) + .push(six.to_packet()) .to_packet()); messages.push(top_level); diff --git a/openpgp/src/serialize/stream.rs b/openpgp/src/serialize/stream.rs index 42c875a7..a5b507bf 100644 --- a/openpgp/src/serialize/stream.rs +++ b/openpgp/src/serialize/stream.rs @@ -506,11 +506,11 @@ impl<'a> Lit |