aboutsummaryrefslogtreecommitdiffstats
path: root/src/message.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/message.rs')
-rw-r--r--src/message.rs17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/message.rs b/src/message.rs
index 32445f6..4dd2fa8 100644
--- a/src/message.rs
+++ b/src/message.rs
@@ -4,6 +4,11 @@ use failure::Error;
use std::convert::{TryFrom, TryInto};
use byteorder::{ByteOrder, LittleEndian};
+#[derive(Deref)] pub struct Initiation(Vec<u8>);
+#[derive(Deref)] pub struct Response(Vec<u8>);
+#[derive(Deref)] pub struct CookieReply(Vec<u8>);
+#[derive(Deref)] pub struct Transport(Vec<u8>);
+
pub enum Message {
Initiation(Initiation),
Response(Response),
@@ -25,9 +30,6 @@ impl TryFrom<Vec<u8>> for Message {
}
}
-#[derive(Deref)]
-pub struct Initiation(Vec<u8>);
-
impl Initiation {
pub fn their_index(&self) -> u32 {
LittleEndian::read_u32(&self[4..])
@@ -51,9 +53,6 @@ impl TryFrom<Vec<u8>> for Initiation {
}
}
-#[derive(Deref)]
-pub struct Response(Vec<u8>);
-
impl Response {
pub fn their_index(&self) -> u32 {
LittleEndian::read_u32(&self[4..])
@@ -89,9 +88,6 @@ impl TryFrom<Vec<u8>> for Response {
}
}
-#[derive(Deref)]
-pub struct CookieReply(Vec<u8>);
-
impl CookieReply {
pub fn our_index(&self) -> u32 {
LittleEndian::read_u32(&self[4..])
@@ -123,9 +119,6 @@ impl TryFrom<Vec<u8>> for CookieReply {
}
}
-#[derive(Deref)]
-pub struct Transport(Vec<u8>);
-
impl Transport {
pub fn our_index(&self) -> u32 {
LittleEndian::read_u32(&self[4..])