blob: 9e1e67188f3f64b3f5a128cd255657fe2e284900 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
use quickcheck::{Arbitrary, Gen};
use crate::packet;
use crate::Packet;
/// Holds a Marker packet.
///
/// See [Section 5.8 of RFC 4880] for details.
///
/// [Section 5.8 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-5.8
#[derive(Clone, Debug)]
pub struct Marker {
/// CTB packet header fields.
pub(crate) common: packet::Common,
}
impl PartialEq for Marker {
fn eq(&self, _other: &Marker) -> bool {
true
}
}
impl Eq for Marker {}
impl std::hash::Hash for Marker {
fn hash<H: std::hash::Hasher>(&self, _state: &mut H) {
}
}
impl Marker {
pub(crate) const BODY: &'static [u8] = &[0x50, 0x47, 0x50];
}
impl Default for Marker {
fn default() -> Self {
Self {
common: Default::default(),
}
}
}
impl From<Marker> for Packet {
fn from(p: Marker) -> Self {
Packet::Marker(p)
}
}
impl Arbitrary for Marker {
fn arbitrary<G: Gen>(_: &mut G) -> Self {
Self::default()
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::parse::Parse;
use crate::serialize::MarshalInto;
#[test]
fn roundtrip() {
let p = Marker::default();
let q = Marker::from_bytes(&p.to_vec().unwrap()).unwrap();
assert_eq!(p, q);
}
}
|