[−][src]Struct sequoia_openpgp::PacketPile
A PacketPile
holds a deserialized sequence of OpenPGP messages.
To deserialize an OpenPGP usage, use either PacketParser
,
PacketPileParser
, or PacketPile::from_file
(or related
routines).
Normally, you'll want to convert the PacketPile
to a Cert or a
Message
.
Methods
impl PacketPile
[src]
pub fn pretty_print(&self)
[src]
Pretty prints the message to stderr.
This function is primarily intended for debugging purposes.
pub fn path_ref(&self, pathspec: &[usize]) -> Option<&Packet>
[src]
Returns a reference to the packet at the location described by
pathspec
.
pathspec
is a slice of the form [ 0, 1, 2 ]
. Each element
is the index of packet in a container. Thus, the previous
path specification means: return the third child of the second
child of the first top-level packet. In other words, the
starred packet in the following tree:
PacketPile
/ | \
0 1 2 ...
/ \
/ \
0 1 ...
/ | \ ...
0 1 2
*
And, [ 10 ]
means return the 11th top-level packet.
Note: there is no packet at the root. Thus, the path []
returns None.
pub fn path_ref_mut(&mut self, pathspec: &[usize]) -> Option<&mut Packet>
[src]
Returns a mutable reference to the packet at the location
described by pathspec
.
See the description of the path_spec
for more details.
pub fn replace(
&mut self,
pathspec: &[usize],
count: usize,
packets: Vec<Packet>
) -> Result<Vec<Packet>>
[src]
&mut self,
pathspec: &[usize],
count: usize,
packets: Vec<Packet>
) -> Result<Vec<Packet>>
Replaces the specified packets at the location described by
pathspec
with packets
.
If a packet is a container, the sub-tree rooted at the container is removed.
Note: the number of packets to remove need not match the number of packets to insert.
The removed packets are returned.
If the path was invalid, then Error::IndexOutOfRange
is
returned instead.
Example
// A compressed data packet that contains a literal data packet. let mut literal = Literal::new(DataFormat::Text); literal.set_body(b"old".to_vec()); let mut compressed = CompressedData::new(CompressionAlgorithm::Uncompressed); compressed.children_mut().push(literal.into()); let mut pile = PacketPile::from(Packet::from(compressed)); // Replace the literal data packet. let mut literal = Literal::new(DataFormat::Text); literal.set_body(b"new".to_vec()); pile.replace( &[ 0, 0 ], 1, [ literal.into() ].to_vec()) .unwrap();
ⓘImportant traits for Iter<'a>pub fn descendants(&self) -> Iter
[src]
Returns an iterator over all of the packet's descendants, in depth-first order.
pub fn children<'a>(&'a self) -> Iter<'a, Packet>
[src]
Returns an iterator over the top-level packets.
pub fn into_children(self) -> IntoIter<Packet>
[src]
Returns an IntoIter
over the top-level packets.
pub fn from_packet_parser<'a>(ppr: PacketParserResult<'a>) -> Result<PacketPile>
[src]
Reads all of the packets from a PacketParser
, and turns them
into a message.
Note: this assumes that ppr
points to a top-level packet.
Trait Implementations
impl Clone for PacketPile
[src]
fn clone(&self) -> PacketPile
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for PacketPile
[src]
impl From<Message> for PacketPile
[src]
impl From<Packet> for PacketPile
[src]
impl From<Vec<Packet>> for PacketPile
[src]
impl FromStr for PacketPile
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
impl<'a> Parse<'a, PacketPile> for PacketPile
[src]
fn from_reader<R: 'a + Read>(reader: R) -> Result<PacketPile>
[src]
Deserializes the OpenPGP message stored in a std::io::Read
object.
Although this method is easier to use to parse a sequence of
OpenPGP packets than a PacketParser
or a
PacketPileParser
, this interface buffers the whole message
in memory. Thus, the caller must be certain that the
deserialized message is not too large.
Note: this interface does buffer the contents of packets.
fn from_file<P: AsRef<Path>>(path: P) -> Result<PacketPile>
[src]
Deserializes the OpenPGP message stored in the file named by
path
.
See from_reader
for more details and caveats.
fn from_bytes<D: AsRef<[u8]> + ?Sized>(data: &'a D) -> Result<PacketPile>
[src]
Deserializes the OpenPGP message stored in the provided buffer.
See from_reader
for more details and caveats.
impl PartialEq<PacketPile> for PacketPile
[src]
fn eq(&self, other: &PacketPile) -> bool
[src]
fn ne(&self, other: &PacketPile) -> bool
[src]
impl Serialize for PacketPile
[src]
fn serialize(&self, o: &mut dyn Write) -> Result<()>
[src]
Writes a serialized version of the specified PacketPile
to o
.
fn export(&self, o: &mut dyn Write) -> Result<()>
[src]
Exports a serialized version of the specified PacketPile
to o
.
impl SerializeInto for PacketPile
[src]
fn serialized_len(&self) -> usize
[src]
fn serialize_into(&self, buf: &mut [u8]) -> Result<usize>
[src]
fn export_into(&self, buf: &mut [u8]) -> Result<usize>
[src]
fn to_vec(&self) -> Result<Vec<u8>>
[src]
fn export_to_vec(&self) -> Result<Vec<u8>>
[src]
impl StructuralPartialEq for PacketPile
[src]
Auto Trait Implementations
impl !RefUnwindSafe for PacketPile
impl Send for PacketPile
impl Sync for PacketPile
impl Unpin for PacketPile
impl !UnwindSafe for PacketPile
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,