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
use super::{NsidMessageBuffer, NSID_HEADER_LEN};
use crate::{
traits::{Emitable, Parseable},
DecodeError,
};
#[derive(Debug, PartialEq, Eq, Clone, Default)]
pub struct NsidHeader {
pub rtgen_family: u8,
}
impl Emitable for NsidHeader {
fn buffer_len(&self) -> usize {
NSID_HEADER_LEN
}
fn emit(&self, buffer: &mut [u8]) {
let mut packet = NsidMessageBuffer::new(buffer);
packet.set_rtgen_family(self.rtgen_family);
}
}
impl<T: AsRef<[u8]>> Parseable<NsidMessageBuffer<T>> for NsidHeader {
fn parse(buf: &NsidMessageBuffer<T>) -> Result<Self, DecodeError> {
Ok(NsidHeader {
rtgen_family: buf.rtgen_family(),
})
}
}