diff --git a/tuic/src/protocol/address.rs b/tuic/src/protocol/address.rs index da3a7f4..717629b 100644 --- a/tuic/src/protocol/address.rs +++ b/tuic/src/protocol/address.rs @@ -15,10 +15,10 @@ use std::{ /// /// The address type can be one of the following: /// -/// 0x00: None -/// 0x01: Fully-qualified domain name (the first byte indicates the length of the domain name) -/// 0x02: IPv4 address -/// 0x03: IPv6 address +/// 0xff: None +/// 0x00: Fully-qualified domain name (the first byte indicates the length of the domain name) +/// 0x01: IPv4 address +/// 0x02: IPv6 address /// /// The port number is encoded in 2 bytes after the Domain name / IP address. #[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] @@ -29,10 +29,10 @@ pub enum Address { } impl Address { - pub const TYPE_CODE_NONE: u8 = 0x00; - pub const TYPE_CODE_DOMAIN: u8 = 0x01; - pub const TYPE_CODE_IPV4: u8 = 0x02; - pub const TYPE_CODE_IPV6: u8 = 0x03; + pub const TYPE_CODE_NONE: u8 = 0xff; + pub const TYPE_CODE_DOMAIN: u8 = 0x00; + pub const TYPE_CODE_IPV4: u8 = 0x01; + pub const TYPE_CODE_IPV6: u8 = 0x02; pub fn type_code(&self) -> u8 { match self { diff --git a/tuic/src/protocol/authenticate.rs b/tuic/src/protocol/authenticate.rs index 9f1a781..988230d 100644 --- a/tuic/src/protocol/authenticate.rs +++ b/tuic/src/protocol/authenticate.rs @@ -13,7 +13,7 @@ pub struct Authenticate { impl Authenticate { pub(super) const TYPE_CODE: u8 = 0x00; - pub fn new(token: [u8; 8]) -> Self { + pub const fn new(token: [u8; 8]) -> Self { Self { token } } } diff --git a/tuic/src/protocol/connect.rs b/tuic/src/protocol/connect.rs index 286eaf7..db57013 100644 --- a/tuic/src/protocol/connect.rs +++ b/tuic/src/protocol/connect.rs @@ -13,7 +13,7 @@ pub struct Connect { impl Connect { pub(super) const TYPE_CODE: u8 = 0x01; - pub fn new(addr: Address) -> Self { + pub const fn new(addr: Address) -> Self { Self { addr } } } diff --git a/tuic/src/protocol/dissociate.rs b/tuic/src/protocol/dissociate.rs index f443f06..d931d13 100644 --- a/tuic/src/protocol/dissociate.rs +++ b/tuic/src/protocol/dissociate.rs @@ -11,9 +11,9 @@ pub struct Dissociate { } impl Dissociate { - pub const TYPE_CODE: u8 = 0x03; + pub(super) const TYPE_CODE: u8 = 0x03; - pub fn new(assoc_id: u16) -> Self { + pub const fn new(assoc_id: u16) -> Self { Self { assoc_id } } } diff --git a/tuic/src/protocol/heartbeat.rs b/tuic/src/protocol/heartbeat.rs index efb7e52..7b03ad1 100644 --- a/tuic/src/protocol/heartbeat.rs +++ b/tuic/src/protocol/heartbeat.rs @@ -9,9 +9,9 @@ use super::Command; pub struct Heartbeat; impl Heartbeat { - pub const TYPE_CODE: u8 = 0x04; + pub(super) const TYPE_CODE: u8 = 0x04; - pub fn new() -> Self { + pub const fn new() -> Self { Self } } diff --git a/tuic/src/protocol/packet.rs b/tuic/src/protocol/packet.rs index 68af7a9..83e4504 100644 --- a/tuic/src/protocol/packet.rs +++ b/tuic/src/protocol/packet.rs @@ -18,7 +18,7 @@ pub struct Packet { impl Packet { pub(super) const TYPE_CODE: u8 = 0x02; - pub fn new( + pub const fn new( assoc_id: u16, pkt_id: u16, frag_total: u8,