Module sequoia_openpgp::parse::map

source ·
Expand description

Packet maps.

If configured to do so, a PacketParser will create a map that charts the byte-stream, describing where the information was extracted from.

§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.
    .buffer_unread_content() // For the packet body.
    .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(0).unwrap().offset(), 0);
assert_eq!(map.iter().nth(0).unwrap().as_bytes(), &[0xcb]);

Structs§

  • Represents an entry in the map.
  • Map created during parsing.