vpgp/packet/
trust.rs

1use std::io;
2
3use log::warn;
4
5use crate::errors::Result;
6use crate::packet::PacketTrait;
7use crate::ser::Serialize;
8use crate::types::{Tag, Version};
9
10/// Trust Packet
11/// <https://www.rfc-editor.org/rfc/rfc9580.html#name-trust-packet-type-id-12>
12///
13/// Trust packets SHOULD NOT be emitted to output streams that are
14/// transferred to other users, and they SHOULD be ignored on any input
15/// other than local keyring files.
16#[derive(Debug, PartialEq, Eq)]
17pub struct Trust {
18    packet_version: Version,
19}
20
21impl Trust {
22    /// Parses a `Trust` packet from the given slice.
23    pub fn from_slice(packet_version: Version, _: &[u8]) -> Result<Self> {
24        warn!("Trust packet detected, ignoring");
25
26        Ok(Trust { packet_version })
27    }
28}
29
30impl Serialize for Trust {
31    fn to_writer<W: io::Write>(&self, _writer: &mut W) -> Result<()> {
32        Ok(())
33    }
34}
35
36impl PacketTrait for Trust {
37    fn packet_version(&self) -> Version {
38        self.packet_version
39    }
40
41    fn tag(&self) -> Tag {
42        Tag::Trust
43    }
44}