summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-11-05 15:50:34 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-11-05 15:50:34 +0100
commit0fdb21c2f446234570c8935ada9f29c7f6392b98 (patch)
treed0eebbff87cae68c163d84e43b3c385c4f48b7c7
parent2e5bf44f1fcbdbcd536064c309b4cbb26b2bc67f (diff)
openpgp: Add new interface to create subpackets.
- Fixes #351.
-rw-r--r--openpgp/src/packet/signature/subpacket.rs20
1 files changed, 14 insertions, 6 deletions
diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs
index c6f27e5c..4b74b3b3 100644
--- a/openpgp/src/packet/signature/subpacket.rs
+++ b/openpgp/src/packet/signature/subpacket.rs
@@ -892,12 +892,20 @@ impl<'a> fmt::Debug for Subpacket<'a> {
impl<'a> Subpacket<'a> {
/// Creates a new subpacket.
- pub fn new(value: SubpacketValue<'a>, critical: bool) -> Result<Subpacket<'a>> {
- Ok(Subpacket {
- critical: critical,
- tag: value.tag()?,
- value: value,
- })
+ pub fn new(value: SubpacketValue<'a>, critical: bool)
+ -> Result<Subpacket<'a>> {
+ Ok(Self::with_tag(value.tag()?, value, critical))
+ }
+
+ /// Creates a new subpacket with the given tag.
+ pub fn with_tag(tag: SubpacketTag, value: SubpacketValue<'a>,
+ critical: bool)
+ -> Subpacket<'a> {
+ Subpacket {
+ critical,
+ tag,
+ value,
+ }
}
/// Returns whether this subpacket is critical.