♻️ refactor: start moving protocol into its own module

main
_ 2021-07-18 17:57:54 +00:00
parent 9b60acf0e0
commit b1af608ab0
6 changed files with 18 additions and 12 deletions

View File

@ -2,6 +2,7 @@ use structopt::StructOpt;
use tokio::net::TcpListener; use tokio::net::TcpListener;
use quic_demo::prelude::*; use quic_demo::prelude::*;
use protocol::Command;
#[derive (Debug, StructOpt)] #[derive (Debug, StructOpt)]
struct Opt { struct Opt {

View File

@ -2,6 +2,7 @@ use structopt::StructOpt;
use tokio::net::TcpStream; use tokio::net::TcpStream;
use quic_demo::prelude::*; use quic_demo::prelude::*;
use protocol::Command;
#[derive (Debug, StructOpt)] #[derive (Debug, StructOpt)]
struct Opt { struct Opt {

View File

@ -1,6 +1,7 @@
use structopt::StructOpt; use structopt::StructOpt;
use quic_demo::prelude::*; use quic_demo::prelude::*;
use protocol::Command;
#[derive (Debug, StructOpt)] #[derive (Debug, StructOpt)]
struct Opt { struct Opt {

View File

@ -1,2 +1,3 @@
pub mod prelude; pub mod prelude;
pub mod protocol;
pub mod quinn_utils; pub mod quinn_utils;

View File

@ -31,16 +31,5 @@ pub use tracing::{
warn, warn,
}; };
pub use crate::protocol;
pub use crate::quinn_utils::*; pub use crate::quinn_utils::*;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Command (pub u8);
impl Command {
pub const CONNECT_P2_TO_P3: Command = Command (2);
pub const CONNECT_P4_TO_P3: Command = Command (4);
pub const CONNECT_P2_TO_P4: Command = Command (10);
pub const CONNECT_P2_TO_P4_STEP_2: Command = Command (11);
pub const CONNECT_P2_TO_P5: Command = Command (12);
pub const OKAY: Command = Command (20);
}

View File

@ -0,0 +1,13 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Command (pub u8);
impl Command {
pub const CONNECT_P2_TO_P3: Command = Command (2);
pub const CONNECT_P4_TO_P3: Command = Command (4);
pub const CONNECT_P2_TO_P4: Command = Command (10);
pub const CONNECT_P2_TO_P4_STEP_2: Command = Command (11);
pub const CONNECT_P2_TO_P5: Command = Command (12);
pub const OKAY: Command = Command (20);
}
// pub fn p2_connect_to_p3 (