diff --git a/builds/ground/src/main.rs b/builds/ground/src/main.rs index 1d844b9..1ddab4c 100644 --- a/builds/ground/src/main.rs +++ b/builds/ground/src/main.rs @@ -10,92 +10,15 @@ use std::{ use anyhow::anyhow; use anyhow::Result; use connector::{Connector, UdpConnector}; +use egui::Ui; use log::*; -use msg::DsTlmSet; +use msg::{DsTlmSet, Msg, TargetMsg, TlmSetItem}; use reflect::*; use rfe::macros::Reflect; use rfe::*; -use serde::{Deserialize, Serialize}; +extern crate alloc; use simple_logger::SimpleLogger; -#[derive(Debug, Clone, Serialize, Deserialize)] -struct TreeNode { - name: String, - children: Vec, -} - -impl TreeNode { - pub fn new(name: T, children: Vec) -> Self { - Self { - name: name.to_string(), - children, - } - } - - pub fn add_child(&mut self, name: T) -> &mut TreeNode { - self.children.push(TreeNode::new(name, Vec::new())); - let i = self.children.len() - 1; - return &mut self.children[i]; - } - - pub fn get_add_path(&mut self, path: &str) -> &mut TreeNode { - if !path.starts_with(&format!("{}.", self.name)) { - return self; - } - let path = path.replace(&format!("{}.", self.name), ""); - let names = path.split("."); - let mut working_tree = self; - - for name in names { - let mut index = None; - for (i, child) in &mut working_tree.children.iter().enumerate() { - if child.name == name { - index = Some(i); - break; - } - } - if let Some(index) = index { - working_tree = &mut working_tree.children[index]; - } else { - working_tree = working_tree.add_child(name); - } - } - - working_tree - } - - pub fn is_last(&self) -> bool { - self.children.len() == 0 - } -} - -fn to_tree(msg_enum: Vec) -> TreeNode { - let mut t = TreeNode::new("Msg", Vec::new()); - for p in msg_enum { - let mut x = p - .split(" = ") - .map(|x| x.split(".")) - .flatten() - .collect::>() - .join("."); - - if x.starts_with(".") { - x.remove(0); - } else { - x = format!("Msg.{}", x); - } - let s = x.rsplitn(2, ".").collect::>(); - - if s.len() == 2 { - t.get_add_path(s[1]).add_child(s[0]); - } else { - t.add_child(s[0]); - } - } - - t -} - #[derive(Debug, Default, Reflect)] struct TestStruct { counter: i8, @@ -114,116 +37,138 @@ fn main() -> Result<()> { .init() .unwrap(); - info!( - "{:?}", - msg::Msg::DsCmd(msg::DsCmd::AddTlmSet(DsTlmSet::default())) - ); - info!( - "json {}", - serde_json::to_string(&msg::Msg::DsCmd(msg::DsCmd::Noop)).unwrap() - ); + spawn(|| { + let mut udp = UdpConnector::new("127.0.0.1", 7011, "127.0.0.1", 7010).unwrap(); - let mut test = TestStruct::default(); - info!("{:?}", test.fields()); - reflect::path_set(&mut test, "counter", ReflectValue::I64(1)); - info!("{:?}", test.fields()); + let mut next_time = Instant::now() + Duration::from_millis(10); + loop { + sleep(next_time - Instant::now()); - let mut test2 = EnumTest::None; + while let Some(msgs) = udp.recv() { + for msg in msgs { + info!("got msg {:?}", msg); + } + } + next_time += Duration::from_millis(10); + } + }); - // info!("{:?}", test2); - - // let testref = test2.as_variant(1).unwrap(); - - // test2.as_variant(1).unwrap().fields()[0] - // .1 - // .set_value(ReflectValue::I64(3)); - // info!("{:?}", test2); - - // spawn(|| { - // let mut udp = UdpConnector::new("127.0.0.1", 7011, "127.0.0.1", 7010).unwrap(); - - // let mut next_time = Instant::now() + Duration::from_millis(10); - // loop { - // sleep(next_time - Instant::now()); - - // while let Some(msgs) = udp.recv() { - // for msg in msgs { - // info!("got msg {:?}", msg); - // } - // } - // next_time += Duration::from_millis(10); - // } - // }); - - // let options = eframe::NativeOptions { - // viewport: egui::ViewportBuilder::default().with_inner_size([560.0, 480.0]), - // ..Default::default() - // }; - // eframe::run_native( - // "RFE Ground", - // options, - // Box::new(|_cc| Ok(Box::::default())), - // ) - // .or(Err(anyhow!("eframe failed")))?; + let options = eframe::NativeOptions { + viewport: egui::ViewportBuilder::default().with_inner_size([560.0, 480.0]), + ..Default::default() + }; + eframe::run_native( + "RFE Ground", + options, + Box::new(|_cc| Ok(Box::::default())), + ) + .or(Err(anyhow!("eframe failed")))?; return Ok(()); } -// struct MyApp { -// command_path: String, -// tree: TreeNode, -// values: HashMap, -// } +struct MyApp { + command: Msg, + values: HashMap, +} -// impl Default for MyApp { -// fn default() -> Self { -// let tree = to_tree(msg::Msg::None.enumerate_clean()); -// Self { -// command_path: "Msg".to_string(), -// tree, -// values: HashMap::new(), -// } -// } -// } +impl Default for MyApp { + fn default() -> Self { + Self { + command: Msg::None, + values: HashMap::new(), + } + } +} -// impl eframe::App for MyApp { -// fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { -// egui::CentralPanel::default().show(ctx, |ui| { -// ui.heading(format!("Commands: {}", self.command_path)); -// if ui.button("X").clicked() { -// self.command_path = "Msg".to_string(); -// } -// if self -// .command_path -// .as_bytes() -// .iter() -// .filter(|x| **x == b'.') -// .count() -// >= 2 -// { -// for item in &self.tree.get_add_path(&self.command_path).children { -// for c in &item.children { -// if c.is_last() { -// if !self.values.contains_key(&c.name) { -// self.values.insert(c.name.clone(), String::new()); -// } -// let sref = self.values.get_mut(&c.name).unwrap(); -// ui.horizontal(|ui| { -// ui.label(format!("{} : {}", item.name, c.name.clone())); -// ui.text_edit_singleline(sref); -// }); -// } -// } -// } -// if ui.button("send").clicked() { -// info!("sending {}", self.command_path); -// } -// } else { -// for item in &self.tree.get_add_path(&self.command_path).children { -// if ui.button(item.name.clone()).clicked() { -// self.command_path = format!("{}.{}", self.command_path, item.name); -// } -// } -// } -// }); -// } -// } +fn build_command_ui_value_number(ui: &mut Ui, name: &str, cmd: &mut dyn Reflect) { + let mut r = cmd.get_value().str(); + ui.horizontal(|ui| { + ui.label(name); + ui.text_edit_singleline(&mut r); + cmd.set_value(ReflectValue::Str(r)); + }); +} + +fn build_command_ui(ui: &mut Ui, name: &str, cmd: &mut dyn Reflect) { + match cmd.reflect_type() { + ReflectType::Value => match cmd.get_value() { + ReflectValue::None => {} + ReflectValue::U8(_) => build_command_ui_value_number(ui, name, cmd), + ReflectValue::U16(_) => build_command_ui_value_number(ui, name, cmd), + ReflectValue::U32(_) => build_command_ui_value_number(ui, name, cmd), + ReflectValue::U64(_) => build_command_ui_value_number(ui, name, cmd), + ReflectValue::I8(_) => build_command_ui_value_number(ui, name, cmd), + ReflectValue::I16(_) => build_command_ui_value_number(ui, name, cmd), + ReflectValue::I32(_) => build_command_ui_value_number(ui, name, cmd), + ReflectValue::I64(_) => build_command_ui_value_number(ui, name, cmd), + ReflectValue::Vec(_vec) => {} + ReflectValue::Str(_) => {} + ReflectValue::Bool(_) => {} + }, + ReflectType::Enumeration => { + // variants + + for (i, (name, _v)) in cmd.variants().into_iter().enumerate() { + if ui.button(name).clicked() { + cmd.convert_variant(i); + } + } + + // values + if let Some((name, cmd)) = cmd.unwrap_variant() { + build_command_ui(ui, name, cmd); + } + } + ReflectType::Structure => { + for (name, cmd) in cmd.fields().into_iter() { + build_command_ui(ui, name, cmd); + } + } + } +} + +impl eframe::App for MyApp { + fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { + egui::CentralPanel::default().show(ctx, |ui| { + ui.heading(format!("Command: {:?}", self.command)); + if ui.button("X").clicked() { + self.command = Msg::None; + } + + build_command_ui(ui, "Msg", &mut self.command); + + // if self + // .command_path + // .as_bytes() + // .iter() + // .filter(|x| **x == b'.') + // .count() + // >= 2 + // { + // for item in &self.tree.get_add_path(&self.command_path).children { + // for c in &item.children { + // if c.is_last() { + // if !self.values.contains_key(&c.name) { + // self.values.insert(c.name.clone(), String::new()); + // } + // let sref = self.values.get_mut(&c.name).unwrap(); + // ui.horizontal(|ui| { + // ui.label(format!("{} : {}", item.name, c.name.clone())); + // ui.text_edit_singleline(sref); + // }); + // } + // } + // } + // if ui.button("send").clicked() { + // info!("sending {}", self.command_path); + // } + // } else { + // for item in &self.tree.get_add_path(&self.command_path).children { + // if ui.button(item.name.clone()).clicked() { + // self.command_path = format!("{}.{}", self.command_path, item.name); + // } + // } + // } + }); + } +} diff --git a/rfe/macros/src/macros.rs b/rfe/macros/src/macros.rs index 9724487..25a79f3 100644 --- a/rfe/macros/src/macros.rs +++ b/rfe/macros/src/macros.rs @@ -147,11 +147,17 @@ pub fn reflect_derive(input: TokenStream) -> TokenStream { rfe::reflect::ReflectValue::None } - fn variants(&self) -> alloc::vec::Vec<(&str, alloc::boxed::Box)> { + fn variants(&self) -> alloc::vec::Vec<(&'static str, alloc::boxed::Box)> { alloc::vec::Vec::new() } - fn as_variant(&mut self, _i: usize) -> Option<&mut dyn rfe::reflect::Reflect> { + fn convert_variant(&mut self, _i: usize) {} + + fn unwrap_variant(&mut self) -> Option<(&str, &mut dyn rfe::reflect::Reflect)> { + None + } + + fn as_vec(&mut self) -> Option> { None } } @@ -162,7 +168,7 @@ pub fn reflect_derive(input: TokenStream) -> TokenStream { Data::Enum(data_enum) => { let variants = data_enum.variants; - let as_arms = variants.iter().enumerate().map(|(i, variant)| { + let convert_arms = variants.iter().enumerate().map(|(i, variant)| { let variant_name = &variant.ident; match &variant.fields { @@ -170,7 +176,6 @@ pub fn reflect_derive(input: TokenStream) -> TokenStream { quote! { if _i == #i { *self = Self::#variant_name; - return Some(self); } } } @@ -178,9 +183,6 @@ pub fn reflect_derive(input: TokenStream) -> TokenStream { quote! { if _i == #i { *self = Self::#variant_name(Default::default()); - if let Self::#variant_name(r) = self { - return Some(r); - } } } } @@ -190,6 +192,27 @@ pub fn reflect_derive(input: TokenStream) -> TokenStream { } }); + let unwrap_arms = variants.iter().enumerate().map(|(_i, variant)| { + let variant_name = &variant.ident; + let variant_name_s = variant_name.to_string(); + + match &variant.fields { + Fields::Unit => { + quote! { + Self::#variant_name => None, + } + } + Fields::Unnamed(_) => { + quote! { + Self::#variant_name(v) => Some((#variant_name_s, v)), + } + } + Fields::Named(_) => { + panic!("Named fields not supported by Reflect"); + } + } + }); + let variant_arms = variants.iter().map(|variant| { let variant_name = &variant.ident; let variant_name_s = variant_name.to_string(); @@ -198,16 +221,18 @@ pub fn reflect_derive(input: TokenStream) -> TokenStream { Fields::Unit => { quote! { { + let name: &'static str = #variant_name_s; let value: alloc::boxed::Box = alloc::boxed::Box::new(Self::#variant_name); - variants.push((#variant_name_s, value)); + variants.push((name, value)); } } } Fields::Unnamed(_) => { quote! { { + let name: &'static str = #variant_name_s; let value: alloc::boxed::Box = alloc::boxed::Box::new(Self::#variant_name(Default::default())); - variants.push((#variant_name_s, value)); + variants.push((name, value)); } } @@ -239,15 +264,24 @@ pub fn reflect_derive(input: TokenStream) -> TokenStream { rfe::reflect::ReflectValue::None } - fn variants(&self) -> alloc::vec::Vec<(&str, alloc::boxed::Box)> { + fn variants(&self) -> alloc::vec::Vec<(&'static str, alloc::boxed::Box)> { let mut variants = alloc::vec::Vec::new(); #(#variant_arms)* variants } - fn as_variant(&mut self, _i: usize) -> Option<&mut dyn rfe::reflect::Reflect> { - #(#as_arms)* - panic!("variant incorrect"); + fn convert_variant(&mut self, _i: usize) { + #(#convert_arms)* + } + + fn unwrap_variant(&mut self) -> Option<(&str, &mut dyn rfe::reflect::Reflect)> { + match self { + #(#unwrap_arms)* + } + } + + fn as_vec(&mut self) -> Option> { + None } } } diff --git a/rfe/src/msg/mod.rs b/rfe/src/msg/mod.rs index c627edc..98f45ad 100644 --- a/rfe/src/msg/mod.rs +++ b/rfe/src/msg/mod.rs @@ -111,6 +111,7 @@ pub type TlmSetId = u16; #[cfg_attr(feature = "reflect", derive(Reflect))] pub struct TlmSetItem { pub target: TargetMsg, + /// decimation 0 means sends every msg, decimation 1 means sends every other, etc pub decimation: u16, pub counter: u16, } diff --git a/rfe/src/reflect.rs b/rfe/src/reflect.rs index f477ee5..506d164 100644 --- a/rfe/src/reflect.rs +++ b/rfe/src/reflect.rs @@ -1,10 +1,25 @@ extern crate alloc; +use core::mem::zeroed; use std::string::ToString; use alloc::boxed::Box; use alloc::string::String; use alloc::vec::Vec; +use hashbrown::HashMap; +pub trait Reflect: std::fmt::Debug { + fn reflect_type(&self) -> ReflectType; + fn type_name(&self) -> &str; + fn fields(&mut self) -> Vec<(&str, &mut dyn Reflect)>; + fn set_value(&mut self, value: ReflectValue); + fn get_value(&self) -> ReflectValue; + fn variants(&self) -> Vec<(&'static str, Box)>; + fn convert_variant(&mut self, i: usize); + fn unwrap_variant(&mut self) -> Option<(&str, &mut dyn Reflect)>; + fn as_vec(&mut self) -> Option>; +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum ReflectType { Value, Enumeration, @@ -39,7 +54,13 @@ impl ReflectValue { ReflectValue::I32(v) => *v as i64, ReflectValue::I64(v) => *v as i64, ReflectValue::Vec(_) => 0, - ReflectValue::Str(_) => 0, + ReflectValue::Str(s) => { + if let Ok(v) = s.parse() { + v + } else { + 0 + } + } ReflectValue::Bool(b) => { if *b { 1 @@ -62,7 +83,13 @@ impl ReflectValue { ReflectValue::I32(v) => *v as u64, ReflectValue::I64(v) => *v as u64, ReflectValue::Vec(_) => 0, - ReflectValue::Str(_) => 0, + ReflectValue::Str(s) => { + if let Ok(v) = s.parse() { + v + } else { + 0 + } + } ReflectValue::Bool(b) => { if *b { 1 @@ -76,7 +103,17 @@ impl ReflectValue { pub fn str(self) -> String { match self { ReflectValue::Str(s) => s, - _ => "".to_string(), + ReflectValue::None => "".to_string(), + ReflectValue::U8(v) => v.to_string(), + ReflectValue::U16(v) => v.to_string(), + ReflectValue::U32(v) => v.to_string(), + ReflectValue::U64(v) => v.to_string(), + ReflectValue::I8(v) => v.to_string(), + ReflectValue::I16(v) => v.to_string(), + ReflectValue::I32(v) => v.to_string(), + ReflectValue::I64(v) => v.to_string(), + ReflectValue::Vec(_v) => "".to_string(), + ReflectValue::Bool(v) => v.to_string(), } } @@ -98,20 +135,14 @@ impl ReflectValue { } pub fn vec(self) -> Vec { - + if let ReflectValue::Vec(v) = self { + v + } else { + Vec::new() + } } } -pub trait Reflect: std::fmt::Debug { - fn reflect_type(&self) -> ReflectType; - fn type_name(&self) -> &str; - fn fields(&mut self) -> Vec<(&str, &mut dyn Reflect)>; - fn set_value(&mut self, value: ReflectValue); - fn get_value(&self) -> ReflectValue; - fn variants(&self) -> Vec<(&str, Box)>; - fn as_variant(&mut self, i: usize) -> Option<&mut dyn Reflect>; -} - pub fn path_set(reflect: &mut dyn Reflect, path: &str, value: ReflectValue) { let mut next = reflect; for p in path.split(".") { @@ -148,6 +179,51 @@ pub fn path_get<'a>(reflect: &'a mut dyn Reflect, path: &str) -> Option<&'a mut Some(next) } +fn _flatten<'a>(reflect: &'a mut dyn Reflect) -> HashMap { + let mut list = HashMap::new(); + + match reflect.reflect_type() { + ReflectType::Value => match reflect.get_value() { + ReflectValue::Vec(_) => { + for (i, r) in reflect.as_vec().unwrap().into_iter().enumerate() { + let map = _flatten(r); + for (sn, v) in map { + list.insert(alloc::format!("[{i}].{}", sn), v); + } + } + } + _ => { + list.insert("".to_string(), reflect); + } + }, + ReflectType::Enumeration => { + if let Some((name, r)) = reflect.unwrap_variant() { + let map = _flatten(r); + for (sn, v) in map { + list.insert(alloc::format!("{}.{}", name, sn), v); + } + } + } + ReflectType::Structure => { + for (name, r) in reflect.fields() { + let map = _flatten(r); + for (sn, v) in map { + list.insert(alloc::format!("{}.{}", name, sn), v); + } + } + } + } + + list +} + +pub fn flatten<'a>(reflect: &'a mut dyn Reflect) -> HashMap { + _flatten(reflect) + .into_iter() + .map(|(k, v)| (k[..k.len() - 1].to_string().replace(".[", "["), v)) + .collect() +} + impl Reflect for u8 { fn reflect_type(&self) -> ReflectType { ReflectType::Value @@ -169,11 +245,17 @@ impl Reflect for u8 { ReflectValue::U8(*self) } - fn variants(&self) -> Vec<(&str, Box)> { + fn variants(&self) -> Vec<(&'static str, Box)> { Vec::new() } - fn as_variant(&mut self, _i: usize) -> Option<&mut dyn Reflect> { + fn convert_variant(&mut self, _i: usize) {} + + fn unwrap_variant(&mut self) -> Option<(&str, &mut dyn Reflect)> { + None + } + + fn as_vec(&mut self) -> Option> { None } } @@ -199,11 +281,17 @@ impl Reflect for u16 { ReflectValue::U16(*self) } - fn variants(&self) -> Vec<(&str, Box)> { + fn variants(&self) -> Vec<(&'static str, Box)> { Vec::new() } - fn as_variant(&mut self, _i: usize) -> Option<&mut dyn Reflect> { + fn convert_variant(&mut self, _i: usize) {} + + fn unwrap_variant(&mut self) -> Option<(&str, &mut dyn Reflect)> { + None + } + + fn as_vec(&mut self) -> Option> { None } } @@ -229,11 +317,17 @@ impl Reflect for u32 { ReflectValue::U32(*self) } - fn variants(&self) -> Vec<(&str, Box)> { + fn variants(&self) -> Vec<(&'static str, Box)> { Vec::new() } - fn as_variant(&mut self, _i: usize) -> Option<&mut dyn Reflect> { + fn convert_variant(&mut self, _i: usize) {} + + fn unwrap_variant(&mut self) -> Option<(&str, &mut dyn Reflect)> { + None + } + + fn as_vec(&mut self) -> Option> { None } } @@ -259,11 +353,17 @@ impl Reflect for u64 { ReflectValue::U64(*self) } - fn variants(&self) -> Vec<(&str, Box)> { + fn variants(&self) -> Vec<(&'static str, Box)> { Vec::new() } - fn as_variant(&mut self, _i: usize) -> Option<&mut dyn Reflect> { + fn convert_variant(&mut self, _i: usize) {} + + fn unwrap_variant(&mut self) -> Option<(&str, &mut dyn Reflect)> { + None + } + + fn as_vec(&mut self) -> Option> { None } } @@ -289,11 +389,17 @@ impl Reflect for i8 { ReflectValue::I8(*self) } - fn variants(&self) -> Vec<(&str, Box)> { + fn variants(&self) -> Vec<(&'static str, Box)> { Vec::new() } - fn as_variant(&mut self, _i: usize) -> Option<&mut dyn Reflect> { + fn convert_variant(&mut self, _i: usize) {} + + fn unwrap_variant(&mut self) -> Option<(&str, &mut dyn Reflect)> { + None + } + + fn as_vec(&mut self) -> Option> { None } } @@ -319,11 +425,17 @@ impl Reflect for i16 { ReflectValue::I16(*self) } - fn variants(&self) -> Vec<(&str, Box)> { + fn variants(&self) -> Vec<(&'static str, Box)> { Vec::new() } - fn as_variant(&mut self, _i: usize) -> Option<&mut dyn Reflect> { + fn convert_variant(&mut self, _i: usize) {} + + fn unwrap_variant(&mut self) -> Option<(&str, &mut dyn Reflect)> { + None + } + + fn as_vec(&mut self) -> Option> { None } } @@ -349,11 +461,17 @@ impl Reflect for i32 { ReflectValue::I32(*self) } - fn variants(&self) -> Vec<(&str, Box)> { + fn variants(&self) -> Vec<(&'static str, Box)> { Vec::new() } - fn as_variant(&mut self, _i: usize) -> Option<&mut dyn Reflect> { + fn convert_variant(&mut self, _i: usize) {} + + fn unwrap_variant(&mut self) -> Option<(&str, &mut dyn Reflect)> { + None + } + + fn as_vec(&mut self) -> Option> { None } } @@ -379,11 +497,17 @@ impl Reflect for i64 { ReflectValue::I64(*self) } - fn variants(&self) -> Vec<(&str, Box)> { + fn variants(&self) -> Vec<(&'static str, Box)> { Vec::new() } - fn as_variant(&mut self, _i: usize) -> Option<&mut dyn Reflect> { + fn convert_variant(&mut self, _i: usize) {} + + fn unwrap_variant(&mut self) -> Option<(&str, &mut dyn Reflect)> { + None + } + + fn as_vec(&mut self) -> Option> { None } } @@ -409,11 +533,17 @@ impl Reflect for String { ReflectValue::Str(self.to_string()) } - fn variants(&self) -> Vec<(&str, Box)> { + fn variants(&self) -> Vec<(&'static str, Box)> { Vec::new() } - fn as_variant(&mut self, _i: usize) -> Option<&mut dyn Reflect> { + fn convert_variant(&mut self, _i: usize) {} + + fn unwrap_variant(&mut self) -> Option<(&str, &mut dyn Reflect)> { + None + } + + fn as_vec(&mut self) -> Option> { None } } @@ -439,11 +569,17 @@ impl Reflect for bool { ReflectValue::Bool(*self) } - fn variants(&self) -> Vec<(&str, Box)> { + fn variants(&self) -> Vec<(&'static str, Box)> { Vec::new() } - fn as_variant(&mut self, _i: usize) -> Option<&mut dyn Reflect> { + fn convert_variant(&mut self, _i: usize) {} + + fn unwrap_variant(&mut self) -> Option<(&str, &mut dyn Reflect)> { + None + } + + fn as_vec(&mut self) -> Option> { None } } @@ -462,18 +598,40 @@ impl Reflect for Vec { } fn set_value(&mut self, value: ReflectValue) { - *self = value.vec(); + if let ReflectValue::Vec(v) = value { + *self = v + .into_iter() + .map(|x| { + let mut t: T = unsafe { zeroed() }; + t.set_value(x); + t + }) + .collect(); + } } fn get_value(&self) -> ReflectValue { - ReflectValue::Bool(*self) + ReflectValue::Vec(self.iter().map(|x| x.get_value()).collect()) } - fn variants(&self) -> Vec<(&str, Box)> { + fn variants(&self) -> Vec<(&'static str, Box)> { Vec::new() } - fn as_variant(&mut self, _i: usize) -> Option<&mut dyn Reflect> { + fn convert_variant(&mut self, _i: usize) {} + + fn unwrap_variant(&mut self) -> Option<(&str, &mut dyn Reflect)> { None } + + fn as_vec<'a>(&'a mut self) -> Option> { + Some( + self.iter_mut() + .map(|x| { + let v: &mut dyn Reflect = x; + v + }) + .collect(), + ) + } } diff --git a/tools/decom/src/decom.rs b/tools/decom/src/decom.rs index 003b11d..bcf1400 100644 --- a/tools/decom/src/decom.rs +++ b/tools/decom/src/decom.rs @@ -12,7 +12,6 @@ use std::{ use anyhow::Result; use bincode::decode_from_std_read; use log::*; -use rfe::to_csv::ToCsvClean; use rfe::{msg::MsgPacket, BINCODE_CONFIG}; use simple_logger::SimpleLogger;