sequoia_openpgp/packet/
marker.rs

1#[cfg(test)]
2use quickcheck::{Arbitrary, Gen};
3
4use crate::packet;
5use crate::Packet;
6
7/// Holds a Marker packet.
8///
9/// See [Section 5.8 of RFC 9580] for details.
10///
11///   [Section 5.8 of RFC 9580]: https://www.rfc-editor.org/rfc/rfc9580.html#section-5.8
12// IMPORTANT: If you add fields to this struct, you need to explicitly
13// IMPORTANT: implement PartialEq, Eq, and Hash.
14#[derive(Default, Clone, Debug, PartialEq, Eq, Hash)]
15pub struct Marker {
16    /// CTB packet header fields.
17    pub(crate) common: packet::Common,
18}
19assert_send_and_sync!(Marker);
20
21impl Marker {
22    pub(crate) const BODY: &'static [u8] = &[0x50, 0x47, 0x50];
23}
24
25impl From<Marker> for Packet {
26    fn from(p: Marker) -> Self {
27        Packet::Marker(p)
28    }
29}
30
31#[cfg(test)]
32impl Arbitrary for Marker {
33    fn arbitrary(_: &mut Gen) -> Self {
34        Self::default()
35    }
36}
37
38#[cfg(test)]
39mod tests {
40    use super::*;
41    use crate::parse::Parse;
42    use crate::serialize::MarshalInto;
43
44    #[test]
45    fn roundtrip() {
46        let p = Marker::default();
47        let q = Marker::from_bytes(&p.to_vec().unwrap()).unwrap();
48        assert_eq!(p, q);
49    }
50}