const-ifying Command::new()
This commit is contained in:
parent
3caa232f13
commit
f7e2926051
@ -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 {
|
||||
|
@ -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 }
|
||||
}
|
||||
}
|
||||
|
@ -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 }
|
||||
}
|
||||
}
|
||||
|
@ -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 }
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user