This commit is contained in:
aozhiwei 2022-01-01 22:26:22 +08:00
parent 3e8a27dd0e
commit 10fa5e3e2e
2 changed files with 22 additions and 3 deletions

View File

@ -1,4 +1,5 @@
use std::rc::Rc;
use std::cell::RefCell;
use std::fs::File;
use protobuf::Message;
use protobuf::descriptor::FieldDescriptorProto_Type;
@ -21,11 +22,13 @@ impl r9::ProtoMsg for MessagesUnion {
obj: &serde_json::Map<String, serde_json::Value>,
id_key: &mut i64,
name_key: &mut String) {
println!("abcd1");
if let MessagesUnion::MtwAliKeyConf(meta) = self {
let pb = &mut meta.p.borrow_mut();
let desc = pb.descriptor();
let mut v = Vec::<u8>::new();
{
v.resize(1024 * 1000, 0);
let mut os = ::protobuf::CodedOutputStream::bytes(&mut v);
for field in desc.fields() {
let field_desc = field.proto();
@ -33,6 +36,7 @@ impl r9::ProtoMsg for MessagesUnion {
Some(v) => {
match field_desc.get_field_type() {
FieldDescriptorProto_Type::TYPE_STRING => {
println!("abcd3");
os.write_string(field_desc.get_number() as u32, "hello");
},
_ => {
@ -46,6 +50,7 @@ impl r9::ProtoMsg for MessagesUnion {
}
}
}
println!("{}", v.len());
let mut slice: &[u8] = v.as_slice();
let is = &mut ::protobuf::CodedInputStream::new(&mut slice);
pb.merge_from(is);
@ -73,11 +78,25 @@ macro_rules! getMeta {
fn main() {
let mut metamgr = MetaMgr::new();
let c = metamgr.get_metalist(1);
let idx = 100;
let idx = 0;
let p = metawrap::MtwAliKeyConf{
p: RefCell::new(crate::mt::AliKeyConf::new())
};
let dummy = Rc::new(p);
metamgr.register_meta(
"/var/data/conf_test/analyseapi/ali_key.json".to_string(),
0,
"".to_string(),
"".to_string(),
MessagesUnion::MtwAliKeyConf(dummy)
);
metamgr.load();
let b = getMeta!(metamgr, MtwAliKeyConf, idx);
match b {
Some(v) => {
//v.get_i64();
println!("abcde22222");
println!("{}", v.p.borrow().get_access_keyid());
println!("{}", v.p.borrow().get_access_secret());
}
None => {

2
third_party/r9 vendored

@ -1 +1 @@
Subproject commit 706be6c8faa1dac2d0824715ab53797e57aaa7af
Subproject commit c8ca016ae7387baf4291feb2769c5475e1a2ae4c