Skip to content

Commit 4925058

Browse files
committed
Add implementation feature to protocol id
1 parent 3732b3f commit 4925058

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/packet/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,25 @@ pub const MESSAGE_NONCE_LENGTH: usize = 12;
2929
/// The Id nonce length (in bytes).
3030
pub const ID_NONCE_LENGTH: usize = 16;
3131

32+
pub struct Nat;
33+
34+
impl ProtocolIdentity<3> for Nat {
35+
const PROTOCOL_ID_BYTES: [u8; 6] = *b"discv5";
36+
const PROTOCOL_VERSION_BYTES: [u8; 2] = 0x0001_u16.to_be_bytes();
37+
const IMPLEMENTATION_FEATURES: [u8; 3] = *b"nat";
38+
}
3239
pub struct DefaultProtocolId {}
3340

3441
impl ProtocolIdentity for DefaultProtocolId {
3542
const PROTOCOL_ID_BYTES: [u8; 6] = *b"discv5";
3643
const PROTOCOL_VERSION_BYTES: [u8; 2] = 0x0001_u16.to_be_bytes();
44+
const IMPLEMENTATION_FEATURES: [u8; 0] = *b"";
3745
}
3846

39-
pub trait ProtocolIdentity {
47+
pub trait ProtocolIdentity<const N: usize = 0>: Sync + Send {
4048
const PROTOCOL_ID_BYTES: [u8; 6];
4149
const PROTOCOL_VERSION_BYTES: [u8; 2];
50+
const IMPLEMENTATION_FEATURES: [u8; N];
4251
}
4352

4453
pub(crate) const MAX_PACKET_SIZE: usize = 1280;

0 commit comments

Comments
 (0)