Struct sequoia_openpgp::parse::map::Field [−][src]
pub struct Field<'a> { /* fields omitted */ }
Expand description
Implementations
Returns the name of the field.
Note: The returned names are for display purposes only and may change in the future.
Examples
use sequoia_openpgp as openpgp; use openpgp::parse::{Parse, PacketParserBuilder}; let message_data = b"\xcb\x12t\x00\x00\x00\x00\x00Hello world."; let pp = PacketParserBuilder::from_bytes(message_data)? .map(true) // Enable mapping. .build()? .expect("One packet, not EOF"); let map = pp.map().expect("Mapping is enabled"); assert_eq!(map.iter().nth(0).unwrap().name(), "CTB"); assert_eq!(map.iter().nth(1).unwrap().name(), "length"); assert_eq!(map.iter().nth(2).unwrap().name(), "format");
Returns the offset of the field in the packet.
Examples
use sequoia_openpgp as openpgp; use openpgp::parse::{Parse, PacketParserBuilder}; let message_data = b"\xcb\x12t\x00\x00\x00\x00\x00Hello world."; let pp = PacketParserBuilder::from_bytes(message_data)? .map(true) // Enable mapping. .build()? .expect("One packet, not EOF"); let map = pp.map().expect("Mapping is enabled"); assert_eq!(map.iter().nth(0).unwrap().offset(), 0); assert_eq!(map.iter().nth(1).unwrap().offset(), 1); assert_eq!(map.iter().nth(2).unwrap().offset(), 2);
Returns the value of the field.
Examples
use sequoia_openpgp as openpgp; use openpgp::parse::{Parse, PacketParserBuilder}; let message_data = b"\xcb\x12t\x00\x00\x00\x00\x00Hello world."; let pp = PacketParserBuilder::from_bytes(message_data)? .map(true) // Enable mapping. .build()? .expect("One packet, not EOF"); let map = pp.map().expect("Mapping is enabled"); assert_eq!(map.iter().nth(0).unwrap().as_bytes(), &[0xcb]); assert_eq!(map.iter().nth(1).unwrap().as_bytes(), &[0x12]); assert_eq!(map.iter().nth(2).unwrap().as_bytes(), "t".as_bytes());
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Field<'a>
impl<'a> UnwindSafe for Field<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self