Skip to content

Commit

Permalink
cargo fmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
b23r0 committed Aug 30, 2022
1 parent 4007484 commit 20da463
Show file tree
Hide file tree
Showing 28 changed files with 3,641 additions and 2,775 deletions.
296 changes: 165 additions & 131 deletions heroinn/src/controller.rs

Large diffs are not rendered by default.

525 changes: 317 additions & 208 deletions heroinn/src/main.rs

Large diffs are not rendered by default.

27 changes: 13 additions & 14 deletions heroinn_client/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
use heroinn_util::{ConnectionInfo, HeroinnProtocol};

use crate::{G_DNA};

pub fn master_configure() -> ConnectionInfo{
use crate::G_DNA;

pub fn master_configure() -> ConnectionInfo {
let size = u64::from_be_bytes(G_DNA.size);

// if not write the line , flag will be compiler optimized.
log::trace!("flag : {:?}" ,G_DNA.flag);
if size == 0{
log::trace!("flag : {:?}", G_DNA.flag);

if size == 0 {
log::debug!("use default config");
return ConnectionInfo{
protocol : HeroinnProtocol::UDP.to_u8(),
address : String::from("127.0.0.1:8000"),
remark : String::from("Default"),
return ConnectionInfo {
protocol: HeroinnProtocol::UDP.to_u8(),
address: String::from("127.0.0.1:8000"),
remark: String::from("Default"),
};
}

if size > 1024{
if size > 1024 {
log::error!("parse master connection info data too long");
std::process::exit(0);
}

let config = match ConnectionInfo::parse(&G_DNA.data[..size as usize].to_vec()){
let config = match ConnectionInfo::parse(&G_DNA.data[..size as usize].to_vec()) {
Ok(p) => p,
Err(_) => {
log::error!("parse master connection info faild");
std::process::exit(0);
},
}
};

config
}
}
Loading

0 comments on commit 20da463

Please sign in to comment.