1
This commit is contained in:
parent
c88b019fb2
commit
463037ecb7
@ -7,6 +7,9 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
protobuf = "2.25.2"
|
||||
serde = "*"
|
||||
serde_derive = "*"
|
||||
serde_json = "*"
|
||||
r9 = { path = "../../third_party/r9" }
|
||||
|
||||
[build-dependencies]
|
||||
|
@ -1,4 +1,7 @@
|
||||
use std::rc::Rc;
|
||||
use std::fs::File;
|
||||
use protobuf::Message;
|
||||
use protobuf::descriptor::FieldDescriptorProto_Type;
|
||||
|
||||
use r9;
|
||||
|
||||
@ -6,12 +9,20 @@ mod test;
|
||||
mod mt;
|
||||
mod metawrap;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum MessagesUnion
|
||||
{
|
||||
XValue(Rc::<XValue>),
|
||||
MtwAliKeyConf(Rc::<metawrap::MtwAliKeyConf>)
|
||||
}
|
||||
|
||||
impl MessagesUnion {
|
||||
|
||||
pub fn from_json(&mut self) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
type XValue = r9::XValue::<test::App>;
|
||||
type MetaMgr = r9::MetaMgr::<MessagesUnion>;
|
||||
|
||||
@ -42,4 +53,20 @@ fn main() {
|
||||
|
||||
}
|
||||
}
|
||||
let mut msg = mt::AliKeyConf::new();
|
||||
msg.set_value(100);
|
||||
msg.set_access_keyid("abcdefg".to_string());
|
||||
let desc = msg.descriptor();
|
||||
for field in desc.fields() {
|
||||
let field_desc = field.proto();
|
||||
if field_desc.get_field_type() == FieldDescriptorProto_Type::TYPE_STRING {
|
||||
print!("field_name:{} value:{}\n", field.name(), field.get_str(&msg));
|
||||
}
|
||||
}
|
||||
|
||||
let f = File::open("/root/pub/2005/1/conf_test/game2005/gameserver.dev/node1/game2005.gameserver.cluster.json").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());
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user