Add json-framed encoding, docs, refactor

This commit is contained in:
Dominik Werder
2024-04-28 18:41:06 +02:00
parent b0eab82c93
commit 1b1e0f5a72
52 changed files with 1539 additions and 454 deletions

View File

@@ -149,6 +149,7 @@ pub trait Events:
fn pulses(&self) -> &VecDeque<u64>;
fn frame_type_id(&self) -> u32;
fn to_min_max_avg(&mut self) -> Box<dyn Events>;
fn to_json_vec_u8(&self) -> Vec<u8>;
fn to_cbor_vec_u8(&self) -> Vec<u8>;
}
@@ -269,6 +270,10 @@ impl Events for Box<dyn Events> {
Events::to_min_max_avg(self.as_mut())
}
fn to_json_vec_u8(&self) -> Vec<u8> {
Events::to_json_vec_u8(self.as_ref())
}
fn to_cbor_vec_u8(&self) -> Vec<u8> {
Events::to_cbor_vec_u8(self.as_ref())
}

View File

@@ -169,8 +169,9 @@ fn equal_string(a: &String, b: &String) -> bool {
a == b
}
fn add_int<T: ops::AddAssign>(a: &mut T, b: &T) {
ops::AddAssign::add_assign(a, todo!());
fn _add_int<T: ops::AddAssign>(a: &mut T, b: &T) {
let _ = b;
ops::AddAssign::add_assign(a, err::todoval());
}
macro_rules! add_int {
@@ -193,22 +194,36 @@ macro_rules! add_string {
macro_rules! div_int {
($a:expr, $b:expr) => {
// TODO what is this used for?
// TODO for average calculation, the accumulator must be large enough!
// Use u64 for all ints, and f32 for all floats.
// Therefore, the name "add" is too general.
//*$a /= $b;
{
let _ = $a;
let _ = $b;
}
};
}
macro_rules! div_bool {
($a:expr, $b:expr) => {
//
// TODO what is this used for?
{
let _ = $a;
let _ = $b;
}
};
}
macro_rules! div_string {
($a:expr, $b:expr) => {
//
// TODO what is this used for?
{
let _ = $a;
let _ = $b;
}
};
}