privatizing fields in header abstraction
This commit is contained in:
parent
99e48ca276
commit
a707943d5a
@ -7,7 +7,7 @@ use super::Command;
|
|||||||
// +-------+
|
// +-------+
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Authenticate {
|
pub struct Authenticate {
|
||||||
pub token: [u8; 8],
|
token: [u8; 8],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Authenticate {
|
impl Authenticate {
|
||||||
@ -16,6 +16,10 @@ impl Authenticate {
|
|||||||
pub const fn new(token: [u8; 8]) -> Self {
|
pub const fn new(token: [u8; 8]) -> Self {
|
||||||
Self { token }
|
Self { token }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn token(&self) -> &[u8; 8] {
|
||||||
|
&self.token
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Command for Authenticate {
|
impl Command for Authenticate {
|
||||||
|
@ -7,7 +7,7 @@ use super::{Address, Command};
|
|||||||
// +----------+
|
// +----------+
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Connect {
|
pub struct Connect {
|
||||||
pub addr: Address,
|
addr: Address,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Connect {
|
impl Connect {
|
||||||
@ -16,6 +16,10 @@ impl Connect {
|
|||||||
pub const fn new(addr: Address) -> Self {
|
pub const fn new(addr: Address) -> Self {
|
||||||
Self { addr }
|
Self { addr }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn addr(&self) -> &Address {
|
||||||
|
&self.addr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Command for Connect {
|
impl Command for Connect {
|
||||||
|
@ -7,7 +7,7 @@ use super::Command;
|
|||||||
// +----------+
|
// +----------+
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Dissociate {
|
pub struct Dissociate {
|
||||||
pub assoc_id: u16,
|
assoc_id: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Dissociate {
|
impl Dissociate {
|
||||||
@ -16,6 +16,10 @@ impl Dissociate {
|
|||||||
pub const fn new(assoc_id: u16) -> Self {
|
pub const fn new(assoc_id: u16) -> Self {
|
||||||
Self { assoc_id }
|
Self { assoc_id }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn assoc_id(&self) -> u16 {
|
||||||
|
self.assoc_id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Command for Dissociate {
|
impl Command for Dissociate {
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
use super::{Address, Command};
|
use super::{Address, Command};
|
||||||
|
|
||||||
// +----------+--------+------------+---------+-----+----------+
|
// +----------+--------+------------+---------+------+----------+
|
||||||
// | ASSOC_ID | PKT_ID | FRAG_TOTAL | FRAG_ID | LEN | ADDR |
|
// | ASSOC_ID | PKT_ID | FRAG_TOTAL | FRAG_ID | SIZE | ADDR |
|
||||||
// +----------+--------+------------+---------+-----+----------+
|
// +----------+--------+------------+---------+------+----------+
|
||||||
// | 2 | 2 | 1 | 1 | 2 | Variable |
|
// | 2 | 2 | 1 | 1 | 2 | Variable |
|
||||||
// +----------+--------+------------+---------+-----+----------+
|
// +----------+--------+------------+---------+------+----------+
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Packet {
|
pub struct Packet {
|
||||||
pub assoc_id: u16,
|
assoc_id: u16,
|
||||||
pub pkt_id: u16,
|
pkt_id: u16,
|
||||||
pub frag_total: u8,
|
frag_total: u8,
|
||||||
pub frag_id: u8,
|
frag_id: u8,
|
||||||
pub len: u16,
|
size: u16,
|
||||||
pub addr: Address,
|
addr: Address,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Packet {
|
impl Packet {
|
||||||
@ -23,7 +23,7 @@ impl Packet {
|
|||||||
pkt_id: u16,
|
pkt_id: u16,
|
||||||
frag_total: u8,
|
frag_total: u8,
|
||||||
frag_id: u8,
|
frag_id: u8,
|
||||||
len: u16,
|
size: u16,
|
||||||
addr: Address,
|
addr: Address,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
@ -31,11 +31,35 @@ impl Packet {
|
|||||||
pkt_id,
|
pkt_id,
|
||||||
frag_total,
|
frag_total,
|
||||||
frag_id,
|
frag_id,
|
||||||
len,
|
size,
|
||||||
addr,
|
addr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn assoc_id(&self) -> u16 {
|
||||||
|
self.assoc_id
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn pkt_id(&self) -> u16 {
|
||||||
|
self.pkt_id
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn frag_total(&self) -> u8 {
|
||||||
|
self.frag_total
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn frag_id(&self) -> u8 {
|
||||||
|
self.frag_id
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn size(&self) -> u16 {
|
||||||
|
self.size
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn addr(&self) -> &Address {
|
||||||
|
&self.addr
|
||||||
|
}
|
||||||
|
|
||||||
pub const fn len_without_addr() -> usize {
|
pub const fn len_without_addr() -> usize {
|
||||||
2 + 2 + 1 + 1 + 2
|
2 + 2 + 1 + 1 + 2
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user