1
0

const-ifying Command::new()

This commit is contained in:
EAimTY 2023-01-24 14:44:02 +09:00
parent 3caa232f13
commit f7e2926051
6 changed files with 15 additions and 15 deletions

View File

@ -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 {

View File

@ -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 }
}
}

View File

@ -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 }
}
}

View File

@ -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 }
}
}

View File

@ -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
}
}

View File

@ -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,