Support framing for container
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
use crate::collect_s::ToCborValue;
|
||||
use crate::collect_s::ToJsonValue;
|
||||
use core::fmt;
|
||||
use serde::Serialize;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
pub trait UserApiType: ToCborValue + ToJsonValue {}
|
||||
pub trait UserApiType {
|
||||
fn into_serializable(self: Box<Self>) -> Box<dyn erased_serde::Serialize>;
|
||||
fn into_serializable_json(self: Box<Self>) -> Box<dyn erased_serde::Serialize>;
|
||||
}
|
||||
|
||||
pub trait ToUserFacingApiType {
|
||||
fn to_user_facing_api_type(self) -> Box<dyn UserApiType>;
|
||||
fn to_user_facing_api_type_box(self: Box<Self>) -> Box<dyn UserApiType>;
|
||||
fn into_user_facing_api_type(self) -> Box<dyn UserApiType>;
|
||||
fn into_user_facing_api_type_box(self: Box<Self>) -> Box<dyn UserApiType>;
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
@@ -20,17 +22,21 @@ impl EmptyStruct {
|
||||
}
|
||||
|
||||
impl ToCborValue for EmptyStruct {
|
||||
fn to_cbor_value(&self) -> Result<ciborium::Value, ciborium::value::Error> {
|
||||
let ret = ciborium::Value::Map(Vec::new());
|
||||
Ok(ret)
|
||||
fn into_fields(self) -> Vec<(String, Box<dyn erased_serde::Serialize>)> {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
fn into_fields_box(self: Box<Self>) -> Vec<(String, Box<dyn erased_serde::Serialize>)> {
|
||||
self.into_fields()
|
||||
}
|
||||
}
|
||||
|
||||
impl ToJsonValue for EmptyStruct {
|
||||
fn to_json_value(&self) -> Result<serde_json::Value, serde_json::Error> {
|
||||
let ret = serde_json::to_value(self);
|
||||
ret
|
||||
impl UserApiType for EmptyStruct {
|
||||
fn into_serializable(self: Box<Self>) -> Box<dyn erased_serde::Serialize> {
|
||||
Box::new(BTreeMap::<String, u32>::new())
|
||||
}
|
||||
|
||||
fn into_serializable_json(self: Box<Self>) -> Box<dyn erased_serde::Serialize> {
|
||||
Box::new(BTreeMap::<String, u32>::new())
|
||||
}
|
||||
}
|
||||
|
||||
impl UserApiType for EmptyStruct {}
|
||||
|
||||
@@ -14,11 +14,13 @@ use std::any::Any;
|
||||
use std::fmt;
|
||||
|
||||
pub trait ToJsonValue: fmt::Debug + Send {
|
||||
fn to_json_value(&self) -> Result<serde_json::Value, serde_json::Error>;
|
||||
fn into_fields(self) -> Vec<(String, Box<dyn erased_serde::Serialize>)>;
|
||||
fn into_fields_box(self: Box<Self>) -> Vec<(String, Box<dyn erased_serde::Serialize>)>;
|
||||
}
|
||||
|
||||
pub trait ToCborValue: fmt::Debug + Send {
|
||||
fn to_cbor_value(&self) -> Result<ciborium::Value, ciborium::value::Error>;
|
||||
fn into_fields(self) -> Vec<(String, Box<dyn erased_serde::Serialize>)>;
|
||||
fn into_fields_box(self: Box<Self>) -> Vec<(String, Box<dyn erased_serde::Serialize>)>;
|
||||
}
|
||||
|
||||
impl AsAnyRef for serde_json::Value {
|
||||
@@ -33,12 +35,6 @@ impl AsAnyMut for serde_json::Value {
|
||||
}
|
||||
}
|
||||
|
||||
impl ToJsonValue for serde_json::Value {
|
||||
fn to_json_value(&self) -> Result<serde_json::Value, serde_json::Error> {
|
||||
Ok(self.clone())
|
||||
}
|
||||
}
|
||||
|
||||
pub trait CollectedDyn: fmt::Debug + TypeName + Send + WithLen + ToUserFacingApiType {}
|
||||
|
||||
impl TypeName for Box<dyn CollectedDyn> {
|
||||
@@ -77,7 +73,14 @@ where
|
||||
{
|
||||
fn ingest(&mut self, src: &mut dyn CollectableDyn) {
|
||||
if let Some(src) = src.as_any_mut().downcast_mut::<<T as CollectorTy>::Input>() {
|
||||
trace!("sees incoming &mut ref");
|
||||
let s1 = any::type_name::<T>();
|
||||
let s2 = any::type_name::<<T as CollectorTy>::Input>();
|
||||
trace!(
|
||||
"sees incoming &mut ref len {} t1 {} t2 {}",
|
||||
src.len(),
|
||||
s1,
|
||||
s2
|
||||
);
|
||||
T::ingest(self, src)
|
||||
} else if let Some(src) = src
|
||||
.as_any_mut()
|
||||
|
||||
@@ -6,26 +6,26 @@ use netpod::RangeFilterStats;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
pub const TERM_FRAME_TYPE_ID: u32 = 0xaa01;
|
||||
pub const ERROR_FRAME_TYPE_ID: u32 = 0xaa02;
|
||||
pub const SITEMTY_NONSPEC_FRAME_TYPE_ID: u32 = 0xaa04;
|
||||
pub const EVENT_QUERY_JSON_STRING_FRAME: u32 = 0x100;
|
||||
pub const EVENTS_0D_FRAME_TYPE_ID: u32 = 0x500;
|
||||
pub const MIN_MAX_AVG_DIM_0_BINS_FRAME_TYPE_ID: u32 = 0x700;
|
||||
pub const MIN_MAX_AVG_DIM_1_BINS_FRAME_TYPE_ID: u32 = 0x800;
|
||||
pub const MIN_MAX_AVG_WAVE_BINS: u32 = 0xa00;
|
||||
pub const WAVE_EVENTS_FRAME_TYPE_ID: u32 = 0xb00;
|
||||
pub const LOG_FRAME_TYPE_ID: u32 = 0xc00;
|
||||
pub const STATS_FRAME_TYPE_ID: u32 = 0xd00;
|
||||
pub const RANGE_COMPLETE_FRAME_TYPE_ID: u32 = 0xe00;
|
||||
pub const EVENT_FULL_FRAME_TYPE_ID: u32 = 0x2200;
|
||||
pub const EVENTS_ITEM_FRAME_TYPE_ID: u32 = 0x2300;
|
||||
pub const STATS_EVENTS_FRAME_TYPE_ID: u32 = 0x2400;
|
||||
pub const ITEMS_2_CHANNEL_EVENTS_FRAME_TYPE_ID: u32 = 0x2500;
|
||||
pub const X_BINNED_SCALAR_EVENTS_FRAME_TYPE_ID: u32 = 0x8800;
|
||||
pub const X_BINNED_WAVE_EVENTS_FRAME_TYPE_ID: u32 = 0x8900;
|
||||
pub const DATABUFFER_EVENT_BLOB_FRAME_TYPE_ID: u32 = 0x8a00;
|
||||
pub const CONTAINER_EVENTS_TYPE_ID: u32 = 0x8b00;
|
||||
pub const TERM_FRAME_TYPE_ID: u32 = 0xaa0001;
|
||||
pub const ERROR_FRAME_TYPE_ID: u32 = 0xaa0002;
|
||||
pub const SITEMTY_NONSPEC_FRAME_TYPE_ID: u32 = 0xaa0004;
|
||||
pub const EVENT_QUERY_JSON_STRING_FRAME: u32 = 0x10000;
|
||||
pub const EVENTS_0D_FRAME_TYPE_ID: u32 = 0x50000;
|
||||
pub const MIN_MAX_AVG_DIM_0_BINS_FRAME_TYPE_ID: u32 = 0x70000;
|
||||
pub const MIN_MAX_AVG_DIM_1_BINS_FRAME_TYPE_ID: u32 = 0x80000;
|
||||
pub const MIN_MAX_AVG_WAVE_BINS: u32 = 0xa0000;
|
||||
pub const WAVE_EVENTS_FRAME_TYPE_ID: u32 = 0xb0000;
|
||||
pub const LOG_FRAME_TYPE_ID: u32 = 0xc0000;
|
||||
pub const STATS_FRAME_TYPE_ID: u32 = 0xd0000;
|
||||
pub const RANGE_COMPLETE_FRAME_TYPE_ID: u32 = 0xe0000;
|
||||
pub const EVENT_FULL_FRAME_TYPE_ID: u32 = 0x220000;
|
||||
pub const EVENTS_ITEM_FRAME_TYPE_ID: u32 = 0x230000;
|
||||
pub const STATS_EVENTS_FRAME_TYPE_ID: u32 = 0x240000;
|
||||
pub const ITEMS_2_CHANNEL_EVENTS_FRAME_TYPE_ID: u32 = 0x250000;
|
||||
pub const X_BINNED_SCALAR_EVENTS_FRAME_TYPE_ID: u32 = 0x880000;
|
||||
pub const X_BINNED_WAVE_EVENTS_FRAME_TYPE_ID: u32 = 0x890000;
|
||||
pub const DATABUFFER_EVENT_BLOB_FRAME_TYPE_ID: u32 = 0x8a0000;
|
||||
pub const CONTAINER_EVENTS_TYPE_ID: u32 = 0xc80000;
|
||||
|
||||
pub fn bool_is_false(j: &bool) -> bool {
|
||||
*j == false
|
||||
|
||||
80
src/subfr.rs
80
src/subfr.rs
@@ -1,109 +1,135 @@
|
||||
use crate::streamitem::CONTAINER_EVENTS_TYPE_ID;
|
||||
use netpod::EnumVariant;
|
||||
|
||||
type SubIdTy = u16;
|
||||
|
||||
pub const VEC_FLAG: SubIdTy = 0x0400;
|
||||
pub const PULSED_FLAG: SubIdTy = 0x0800;
|
||||
|
||||
pub trait SubFrId {
|
||||
const SUB: u32;
|
||||
const SUB: SubIdTy;
|
||||
}
|
||||
|
||||
impl SubFrId for u8 {
|
||||
const SUB: u32 = 0x03;
|
||||
const SUB: SubIdTy = 0x01;
|
||||
}
|
||||
|
||||
impl SubFrId for u16 {
|
||||
const SUB: u32 = 0x05;
|
||||
const SUB: SubIdTy = 0x02;
|
||||
}
|
||||
|
||||
impl SubFrId for u32 {
|
||||
const SUB: u32 = 0x08;
|
||||
const SUB: SubIdTy = 0x03;
|
||||
}
|
||||
|
||||
impl SubFrId for u64 {
|
||||
const SUB: u32 = 0x0a;
|
||||
const SUB: SubIdTy = 0x04;
|
||||
}
|
||||
|
||||
impl SubFrId for i8 {
|
||||
const SUB: u32 = 0x02;
|
||||
const SUB: SubIdTy = 0x05;
|
||||
}
|
||||
|
||||
impl SubFrId for i16 {
|
||||
const SUB: u32 = 0x04;
|
||||
const SUB: SubIdTy = 0x06;
|
||||
}
|
||||
|
||||
impl SubFrId for i32 {
|
||||
const SUB: u32 = 0x07;
|
||||
const SUB: SubIdTy = 0x07;
|
||||
}
|
||||
|
||||
impl SubFrId for i64 {
|
||||
const SUB: u32 = 0x09;
|
||||
const SUB: SubIdTy = 0x08;
|
||||
}
|
||||
|
||||
impl SubFrId for f32 {
|
||||
const SUB: u32 = 0x0b;
|
||||
const SUB: SubIdTy = 0x09;
|
||||
}
|
||||
|
||||
impl SubFrId for f64 {
|
||||
const SUB: u32 = 0x0c;
|
||||
const SUB: SubIdTy = 0x0a;
|
||||
}
|
||||
|
||||
impl SubFrId for bool {
|
||||
const SUB: u32 = 0x0d;
|
||||
const SUB: SubIdTy = 0x0b;
|
||||
}
|
||||
|
||||
impl SubFrId for String {
|
||||
const SUB: u32 = 0x0e;
|
||||
const SUB: SubIdTy = 0x0c;
|
||||
}
|
||||
|
||||
impl SubFrId for EnumVariant {
|
||||
const SUB: u32 = 0x0f;
|
||||
const SUB: SubIdTy = 0x0d;
|
||||
}
|
||||
|
||||
impl SubFrId for Vec<u8> {
|
||||
const SUB: u32 = 0x23;
|
||||
const SUB: SubIdTy = VEC_FLAG | <u8 as SubFrId>::SUB;
|
||||
}
|
||||
|
||||
impl SubFrId for Vec<u16> {
|
||||
const SUB: u32 = 0x25;
|
||||
const SUB: SubIdTy = VEC_FLAG | <u16 as SubFrId>::SUB;
|
||||
}
|
||||
|
||||
impl SubFrId for Vec<u32> {
|
||||
const SUB: u32 = 0x28;
|
||||
const SUB: SubIdTy = VEC_FLAG | <u32 as SubFrId>::SUB;
|
||||
}
|
||||
|
||||
impl SubFrId for Vec<u64> {
|
||||
const SUB: u32 = 0x2a;
|
||||
const SUB: SubIdTy = VEC_FLAG | <u64 as SubFrId>::SUB;
|
||||
}
|
||||
|
||||
impl SubFrId for Vec<i8> {
|
||||
const SUB: u32 = 0x22;
|
||||
const SUB: SubIdTy = VEC_FLAG | <i8 as SubFrId>::SUB;
|
||||
}
|
||||
|
||||
impl SubFrId for Vec<i16> {
|
||||
const SUB: u32 = 0x24;
|
||||
const SUB: SubIdTy = VEC_FLAG | <i16 as SubFrId>::SUB;
|
||||
}
|
||||
|
||||
impl SubFrId for Vec<i32> {
|
||||
const SUB: u32 = 0x27;
|
||||
const SUB: SubIdTy = VEC_FLAG | <i32 as SubFrId>::SUB;
|
||||
}
|
||||
|
||||
impl SubFrId for Vec<i64> {
|
||||
const SUB: u32 = 0x29;
|
||||
const SUB: SubIdTy = VEC_FLAG | <i64 as SubFrId>::SUB;
|
||||
}
|
||||
|
||||
impl SubFrId for Vec<f32> {
|
||||
const SUB: u32 = 0x2b;
|
||||
const SUB: SubIdTy = VEC_FLAG | <f32 as SubFrId>::SUB;
|
||||
}
|
||||
|
||||
impl SubFrId for Vec<f64> {
|
||||
const SUB: u32 = 0x2c;
|
||||
const SUB: SubIdTy = VEC_FLAG | <f64 as SubFrId>::SUB;
|
||||
}
|
||||
|
||||
impl SubFrId for Vec<bool> {
|
||||
const SUB: u32 = 0x2d;
|
||||
const SUB: SubIdTy = VEC_FLAG | <bool as SubFrId>::SUB;
|
||||
}
|
||||
|
||||
impl SubFrId for Vec<String> {
|
||||
const SUB: u32 = 0x2e;
|
||||
const SUB: SubIdTy = VEC_FLAG | <String as SubFrId>::SUB;
|
||||
}
|
||||
|
||||
impl SubFrId for Vec<EnumVariant> {
|
||||
const SUB: u32 = 0x2f;
|
||||
const SUB: SubIdTy = VEC_FLAG | <EnumVariant as SubFrId>::SUB;
|
||||
}
|
||||
|
||||
pub const fn is_vec_subfr(x: SubIdTy) -> bool {
|
||||
x & VEC_FLAG != 0
|
||||
}
|
||||
|
||||
pub const fn pulsed_subfr(x: SubIdTy) -> SubIdTy {
|
||||
PULSED_FLAG | x
|
||||
}
|
||||
|
||||
pub const fn is_pulsed_subfr(x: SubIdTy) -> bool {
|
||||
x & PULSED_FLAG != 0
|
||||
}
|
||||
|
||||
pub const fn subfr_scalar_type(x: SubIdTy) -> SubIdTy {
|
||||
x & 0xff
|
||||
}
|
||||
|
||||
pub const fn is_container_events(x: u32) -> bool {
|
||||
x & 0xffff0000 == CONTAINER_EVENTS_TYPE_ID
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
use crate::apitypes::ToUserFacingApiType;
|
||||
use crate::collect_s::CollectableDyn;
|
||||
use crate::collect_s::CollectorDyn;
|
||||
use crate::collect_s::ToCborValue;
|
||||
use crate::collect_s::ToJsonValue;
|
||||
use crate::container::ByteEstimate;
|
||||
use crate::merge::DrainIntoDstResult;
|
||||
use crate::merge::DrainIntoNewDynResult;
|
||||
@@ -98,8 +95,6 @@ pub trait BinningggContainerEventsDyn:
|
||||
+ WithLen
|
||||
+ ByteEstimate
|
||||
+ MergeableDyn
|
||||
+ ToJsonValue
|
||||
+ ToCborValue
|
||||
+ ToUserFacingApiType
|
||||
+ CollectableDyn
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user