summaryrefslogtreecommitdiffstats
path: root/openpgp
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-09-10 15:23:55 +0200
committerJustus Winter <justus@sequoia-pgp.org>2019-09-10 15:23:55 +0200
commit8495b849255551f14b81d7bce6e3c0fce6957df3 (patch)
tree6fe83583ddbc4b2c777c301d44ffa8f23d676062 /openpgp
parentdf47e8c08f06f79ab13ceea435044c37e40000d1 (diff)
openpgp: Make fields of parse::map::Field private.
Diffstat (limited to 'openpgp')
-rw-r--r--openpgp/src/parse/map.rs31
1 files changed, 26 insertions, 5 deletions
diff --git a/openpgp/src/parse/map.rs b/openpgp/src/parse/map.rs
index 2736e790..cb72a1b2 100644
--- a/openpgp/src/parse/map.rs
+++ b/openpgp/src/parse/map.rs
@@ -66,7 +66,8 @@ impl Map {
/// let ppo = PacketParserBuilder::from_bytes(msg)?
/// .map(true).finalize()?;
/// assert_eq!(ppo.unwrap().map().unwrap().iter()
- /// .map(|f| (f.name, f.data)).collect::<Vec<(&str, &[u8])>>(),
+ /// .map(|f| (f.name(), f.data()))
+ /// .collect::<Vec<(&str, &[u8])>>(),
/// [("CTB", &b"\xcb"[..]),
/// ("length", &b"\x12"[..]),
/// ("format", b"t"),
@@ -85,13 +86,13 @@ impl Map {
#[derive(Clone, Debug)]
pub struct Field<'a> {
/// Name of the field.
- pub name: &'static str,
+ name: &'static str,
/// Offset of the field in the packet.
- pub offset: usize,
+ offset: usize,
/// Length of the field.
- pub length: usize,
+ length: usize,
/// Value of the field.
- pub data: &'a [u8],
+ data: &'a [u8],
}
impl<'a> Field<'a> {
@@ -128,6 +129,26 @@ impl<'a> Field<'a> {
})
}
}
+
+ /// Returns the name of the field.
+ pub fn name(&self) -> &'a str {
+ self.name
+ }
+
+ /// Returns the offset of the field in the packet.
+ pub fn offset(&self) -> usize {
+ self.offset
+ }
+
+ /// Returns the length of the field.
+ pub fn length(&self) -> usize {
+ self.length
+ }
+
+ /// Returns the value of the field.
+ pub fn data(&self) -> &'a [u8] {
+ self.data
+ }
}
/// An iterator over the map.