summaryrefslogtreecommitdiffstats
path: root/openpgp
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2020-05-20 13:20:59 +0200
committerNeal H. Walfield <neal@pep.foundation>2020-05-20 13:20:59 +0200
commitdb15fab0b50a5a0bd570632a89c2761861258a65 (patch)
tree30996eadb4ce96b51f8e33eee0d2a7be432a8710 /openpgp
parentd73b750daa0a3eada2e42154ccd6fbc553ead55e (diff)
openpgp: Make field private, provide an accessor
- Don't export `CTBOld::length_type`. Provide a getter, `CTBOld::length_type`, instead.
Diffstat (limited to 'openpgp')
-rw-r--r--openpgp/src/packet/header/ctb.rs7
-rw-r--r--openpgp/src/parse.rs2
-rw-r--r--openpgp/src/serialize.rs2
3 files changed, 8 insertions, 3 deletions
diff --git a/openpgp/src/packet/header/ctb.rs b/openpgp/src/packet/header/ctb.rs
index b6cbd457..073798f5 100644
--- a/openpgp/src/packet/header/ctb.rs
+++ b/openpgp/src/packet/header/ctb.rs
@@ -110,7 +110,7 @@ pub struct CTBOld {
/// Common CTB fields.
common: CTBCommon,
/// Type of length specifier.
- pub length_type: PacketLengthType,
+ length_type: PacketLengthType,
}
impl CTBOld {
@@ -163,6 +163,11 @@ impl CTBOld {
pub fn tag(&self) -> Tag {
self.common.tag
}
+
+ /// Returns the packet's length type.
+ pub fn length_type(&self) -> PacketLengthType {
+ self.length_type
+ }
}
/// A sum type for the different CTB variants.
diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs
index e555c66a..eb9e1175 100644
--- a/openpgp/src/parse.rs
+++ b/openpgp/src/parse.rs
@@ -1012,7 +1012,7 @@ impl Header {
let length = match ctb {
CTB::New(_) => BodyLength::parse_new_format(bio)?,
CTB::Old(ref ctb) =>
- BodyLength::parse_old_format(bio, ctb.length_type)?,
+ BodyLength::parse_old_format(bio, ctb.length_type())?,
};
return Ok(Header::new(ctb, length));
}
diff --git a/openpgp/src/serialize.rs b/openpgp/src/serialize.rs
index a9ff6a7e..476e77be 100644
--- a/openpgp/src/serialize.rs
+++ b/openpgp/src/serialize.rs
@@ -755,7 +755,7 @@ impl MarshalInto for CTBNew {
impl Marshal for CTBOld {
fn serialize(&self, o: &mut dyn std::io::Write) -> Result<()> {
let tag: u8 = self.tag().into();
- let length_type: u8 = self.length_type.into();
+ let length_type: u8 = self.length_type().into();
o.write_all(&[0b1000_0000u8 | (tag << 2) | length_type])?;
Ok(())
}