This commit is contained in:
aozhiwei 2021-12-31 19:04:57 +08:00
parent 463037ecb7
commit ad26515590
3 changed files with 21 additions and 10 deletions

View File

@ -6,11 +6,11 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
protobuf = "2.25.2" protobuf = "2.9.0"
serde = "*" serde = "*"
serde_derive = "*" serde_derive = "*"
serde_json = "*" serde_json = "*"
r9 = { path = "../../third_party/r9" } r9 = { path = "../../third_party/r9" }
[build-dependencies] [build-dependencies]
protobuf-codegen-pure = "2.25.2" protobuf-codegen-pure = "2.9.0"

View File

@ -15,10 +15,14 @@ pub enum MessagesUnion
MtwAliKeyConf(Rc::<metawrap::MtwAliKeyConf>) MtwAliKeyConf(Rc::<metawrap::MtwAliKeyConf>)
} }
impl MessagesUnion { impl r9::ProtoMsg for MessagesUnion {
pub fn from_json(&mut self) {
fn get_proto(&self) -> &dyn Message {
match self {
MessagesUnion::MtwAliKeyConf(v) => {
return &v.p;
}
}
} }
} }
@ -64,9 +68,16 @@ fn main() {
} }
} }
let f = File::open("/root/pub/2005/1/conf_test/game2005/gameserver.dev/node1/game2005.gameserver.cluster.json").unwrap(); let result = File::open("/root/pub/2005/1/conf_test/game2005/gameserver.dev/node1/game2005.gameserver.cluster.json1");
let v: serde_json::Value = serde_json::from_reader(f).unwrap(); match result {
println!("{:?}", v[0]["ip"].as_str().unwrap()); Ok(f) => {
println!("{:?}", v[0]["instance_id"].as_i64().unwrap()); let v: serde_json::Value = serde_json::from_reader(f).unwrap();
println!("{:?}", v[0]["ip"].as_str().unwrap());
println!("{:?}", v[0]["instance_id"].as_i64().unwrap());
}
Err(e) => {
}
}
} }

View File

@ -1,3 +1,3 @@
pub struct MtwAliKeyConf { pub struct MtwAliKeyConf {
pub i: crate::mt::AliKeyConf pub p: crate::mt::AliKeyConf
} }