WIP on get channel info for arch app
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
use crate::agg::streams::StreamItem;
|
||||
use crate::frame::makeframe::{INMEM_FRAME_FOOT, INMEM_FRAME_HEAD, INMEM_FRAME_MAGIC};
|
||||
use bytes::{BufMut, Bytes, BytesMut};
|
||||
use err::Error;
|
||||
use futures_core::Stream;
|
||||
use futures_util::pin_mut;
|
||||
use items::StreamItem;
|
||||
use items::{INMEM_FRAME_FOOT, INMEM_FRAME_HEAD, INMEM_FRAME_MAGIC};
|
||||
use netpod::log::*;
|
||||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
@@ -1,256 +1,9 @@
|
||||
use crate::agg::enp::{WaveEvents, XBinnedScalarEvents, XBinnedWaveEvents};
|
||||
use crate::agg::eventbatch::MinMaxAvgScalarEventBatch;
|
||||
use crate::agg::scalarbinbatch::MinMaxAvgScalarBinBatch;
|
||||
use crate::agg::streams::StreamItem;
|
||||
use crate::binned::dim1::MinMaxAvgDim1Bins;
|
||||
use crate::binned::{MinMaxAvgBins, MinMaxAvgWaveBins, NumOps, RangeCompletableItem};
|
||||
use crate::decode::EventValues;
|
||||
use crate::frame::inmem::InMemoryFrame;
|
||||
use crate::raw::EventQueryJsonStringFrame;
|
||||
use crate::Sitemty;
|
||||
use bytes::{BufMut, BytesMut};
|
||||
use err::Error;
|
||||
use netpod::BoolNum;
|
||||
use items::{FrameType, INMEM_FRAME_ENCID, INMEM_FRAME_HEAD, INMEM_FRAME_MAGIC};
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
|
||||
pub const INMEM_FRAME_ENCID: u32 = 0x12121212;
|
||||
pub const INMEM_FRAME_HEAD: usize = 20;
|
||||
pub const INMEM_FRAME_FOOT: usize = 4;
|
||||
pub const INMEM_FRAME_MAGIC: u32 = 0xc6c3b73d;
|
||||
|
||||
pub trait SubFrId {
|
||||
const SUB: u32;
|
||||
}
|
||||
|
||||
impl SubFrId for u8 {
|
||||
const SUB: u32 = 3;
|
||||
}
|
||||
|
||||
impl SubFrId for u16 {
|
||||
const SUB: u32 = 5;
|
||||
}
|
||||
|
||||
impl SubFrId for u32 {
|
||||
const SUB: u32 = 8;
|
||||
}
|
||||
|
||||
impl SubFrId for u64 {
|
||||
const SUB: u32 = 10;
|
||||
}
|
||||
|
||||
impl SubFrId for i8 {
|
||||
const SUB: u32 = 2;
|
||||
}
|
||||
|
||||
impl SubFrId for i16 {
|
||||
const SUB: u32 = 4;
|
||||
}
|
||||
|
||||
impl SubFrId for i32 {
|
||||
const SUB: u32 = 7;
|
||||
}
|
||||
|
||||
impl SubFrId for i64 {
|
||||
const SUB: u32 = 9;
|
||||
}
|
||||
|
||||
impl SubFrId for f32 {
|
||||
const SUB: u32 = 11;
|
||||
}
|
||||
|
||||
impl SubFrId for f64 {
|
||||
const SUB: u32 = 12;
|
||||
}
|
||||
|
||||
impl SubFrId for BoolNum {
|
||||
const SUB: u32 = 13;
|
||||
}
|
||||
|
||||
pub trait FrameType {
|
||||
const FRAME_TYPE_ID: u32;
|
||||
}
|
||||
|
||||
impl FrameType for EventQueryJsonStringFrame {
|
||||
const FRAME_TYPE_ID: u32 = 0x100;
|
||||
}
|
||||
|
||||
impl FrameType for Sitemty<MinMaxAvgScalarBinBatch> {
|
||||
const FRAME_TYPE_ID: u32 = 0x200;
|
||||
}
|
||||
|
||||
impl FrameType for Sitemty<MinMaxAvgScalarEventBatch> {
|
||||
const FRAME_TYPE_ID: u32 = 0x300;
|
||||
}
|
||||
|
||||
impl<NTY> FrameType for Sitemty<EventValues<NTY>>
|
||||
where
|
||||
NTY: NumOps,
|
||||
{
|
||||
const FRAME_TYPE_ID: u32 = 0x500 + NTY::SUB;
|
||||
}
|
||||
|
||||
impl<NTY> FrameType for Sitemty<XBinnedScalarEvents<NTY>>
|
||||
where
|
||||
NTY: SubFrId,
|
||||
{
|
||||
const FRAME_TYPE_ID: u32 = 0x600 + NTY::SUB;
|
||||
}
|
||||
|
||||
impl<NTY> FrameType for Sitemty<MinMaxAvgBins<NTY>>
|
||||
where
|
||||
NTY: SubFrId,
|
||||
{
|
||||
const FRAME_TYPE_ID: u32 = 0x700 + NTY::SUB;
|
||||
}
|
||||
|
||||
impl<NTY> FrameType for Sitemty<WaveEvents<NTY>>
|
||||
where
|
||||
NTY: SubFrId,
|
||||
{
|
||||
const FRAME_TYPE_ID: u32 = 0x800 + NTY::SUB;
|
||||
}
|
||||
|
||||
impl<NTY> FrameType for Sitemty<XBinnedWaveEvents<NTY>>
|
||||
where
|
||||
NTY: SubFrId,
|
||||
{
|
||||
const FRAME_TYPE_ID: u32 = 0x900 + NTY::SUB;
|
||||
}
|
||||
|
||||
impl<NTY> FrameType for Sitemty<MinMaxAvgWaveBins<NTY>>
|
||||
where
|
||||
NTY: SubFrId,
|
||||
{
|
||||
const FRAME_TYPE_ID: u32 = 0xa00 + NTY::SUB;
|
||||
}
|
||||
|
||||
impl<NTY> FrameType for Sitemty<MinMaxAvgDim1Bins<NTY>>
|
||||
where
|
||||
NTY: SubFrId,
|
||||
{
|
||||
const FRAME_TYPE_ID: u32 = 0xb00 + NTY::SUB;
|
||||
}
|
||||
|
||||
pub trait ProvidesFrameType {
|
||||
fn frame_type_id(&self) -> u32;
|
||||
}
|
||||
|
||||
pub trait Framable: Send {
|
||||
fn typeid(&self) -> u32;
|
||||
fn make_frame(&self) -> Result<BytesMut, Error>;
|
||||
}
|
||||
|
||||
impl Framable for Sitemty<serde_json::Value> {
|
||||
fn typeid(&self) -> u32 {
|
||||
EventQueryJsonStringFrame::FRAME_TYPE_ID
|
||||
}
|
||||
fn make_frame(&self) -> Result<BytesMut, Error> {
|
||||
panic!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Framable for Result<StreamItem<RangeCompletableItem<MinMaxAvgScalarBinBatch>>, Error> {
|
||||
fn typeid(&self) -> u32 {
|
||||
Self::FRAME_TYPE_ID
|
||||
}
|
||||
fn make_frame(&self) -> Result<BytesMut, Error> {
|
||||
make_frame(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Framable for Result<StreamItem<RangeCompletableItem<MinMaxAvgScalarEventBatch>>, Error> {
|
||||
fn typeid(&self) -> u32 {
|
||||
Self::FRAME_TYPE_ID
|
||||
}
|
||||
fn make_frame(&self) -> Result<BytesMut, Error> {
|
||||
make_frame(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<NTY> Framable for Result<StreamItem<RangeCompletableItem<EventValues<NTY>>>, err::Error>
|
||||
where
|
||||
NTY: NumOps + Serialize,
|
||||
{
|
||||
fn typeid(&self) -> u32 {
|
||||
Self::FRAME_TYPE_ID
|
||||
}
|
||||
fn make_frame(&self) -> Result<BytesMut, Error> {
|
||||
make_frame(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<NTY> Framable for Result<StreamItem<RangeCompletableItem<XBinnedScalarEvents<NTY>>>, err::Error>
|
||||
where
|
||||
NTY: NumOps + Serialize,
|
||||
{
|
||||
fn typeid(&self) -> u32 {
|
||||
Self::FRAME_TYPE_ID
|
||||
}
|
||||
fn make_frame(&self) -> Result<BytesMut, Error> {
|
||||
make_frame(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<NTY> Framable for Sitemty<MinMaxAvgBins<NTY>>
|
||||
where
|
||||
NTY: NumOps + Serialize,
|
||||
{
|
||||
fn typeid(&self) -> u32 {
|
||||
Self::FRAME_TYPE_ID
|
||||
}
|
||||
fn make_frame(&self) -> Result<BytesMut, Error> {
|
||||
make_frame(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<NTY> Framable for Sitemty<WaveEvents<NTY>>
|
||||
where
|
||||
NTY: NumOps + Serialize,
|
||||
{
|
||||
fn typeid(&self) -> u32 {
|
||||
Self::FRAME_TYPE_ID
|
||||
}
|
||||
fn make_frame(&self) -> Result<BytesMut, Error> {
|
||||
make_frame(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<NTY> Framable for Sitemty<XBinnedWaveEvents<NTY>>
|
||||
where
|
||||
NTY: NumOps + Serialize,
|
||||
{
|
||||
fn typeid(&self) -> u32 {
|
||||
Self::FRAME_TYPE_ID
|
||||
}
|
||||
fn make_frame(&self) -> Result<BytesMut, Error> {
|
||||
make_frame(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<NTY> Framable for Sitemty<MinMaxAvgWaveBins<NTY>>
|
||||
where
|
||||
NTY: NumOps + Serialize,
|
||||
{
|
||||
fn typeid(&self) -> u32 {
|
||||
Self::FRAME_TYPE_ID
|
||||
}
|
||||
fn make_frame(&self) -> Result<BytesMut, Error> {
|
||||
make_frame(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<NTY> Framable for Sitemty<MinMaxAvgDim1Bins<NTY>>
|
||||
where
|
||||
NTY: NumOps + Serialize,
|
||||
{
|
||||
fn typeid(&self) -> u32 {
|
||||
Self::FRAME_TYPE_ID
|
||||
}
|
||||
fn make_frame(&self) -> Result<BytesMut, Error> {
|
||||
make_frame(self)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn make_frame<FT>(item: &FT) -> Result<BytesMut, Error>
|
||||
where
|
||||
FT: FrameType + Serialize,
|
||||
|
||||
Reference in New Issue
Block a user