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
use pnet_macros_support::packet::PrimitiveValues;
include!(concat!(env!("OUT_DIR"), "/discord.rs"));
const IP_DISCOVERY_LEN: usize = IpDiscoveryPacket::minimum_packet_size() + 64;
impl IpDiscoveryPacket<'_> {
pub const fn const_packet_size() -> usize {
IP_DISCOVERY_LEN
}
}
impl MutableIpDiscoveryPacket<'_> {
pub const fn const_packet_size() -> usize {
IP_DISCOVERY_LEN
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum IpDiscoveryType {
Request,
Response,
Other(u16),
}
impl IpDiscoveryType {
fn new(val: u16) -> Self {
match val {
1 => Self::Request,
2 => Self::Response,
_ => Self::Other(val),
}
}
}
impl PrimitiveValues for IpDiscoveryType {
type T = (u16,);
fn to_primitive_values(&self) -> Self::T {
match self {
Self::Request => (1,),
Self::Response => (2,),
Self::Other(n) => (*n,),
}
}
}