Pulse id diff in events endpoint via transform chain

This commit is contained in:
Dominik Werder
2023-04-19 11:30:18 +02:00
parent abd9cfdf65
commit a94d68aa49
24 changed files with 421 additions and 200 deletions

View File

@@ -122,6 +122,8 @@ pub trait Events:
fn nty_id(&self) -> u32;
fn tss(&self) -> &VecDeque<u64>;
fn pulses(&self) -> &VecDeque<u64>;
fn frame_type_id(&self) -> u32;
fn to_min_max_avg(&mut self) -> Box<dyn Events>;
}
impl WithLen for Box<dyn Events> {
@@ -150,82 +152,90 @@ impl EventsNonObj for Box<dyn Events> {
impl Events for Box<dyn Events> {
fn as_time_binnable_mut(&mut self) -> &mut dyn TimeBinnable {
todo!()
Events::as_time_binnable_mut(self.as_mut())
}
fn verify(&self) -> bool {
todo!()
Events::verify(self.as_ref())
}
fn output_info(&self) {
todo!()
Events::output_info(self.as_ref())
}
fn as_collectable_mut(&mut self) -> &mut dyn Collectable {
todo!()
Events::as_collectable_mut(self.as_mut())
}
fn as_collectable_with_default_ref(&self) -> &dyn Collectable {
todo!()
Events::as_collectable_with_default_ref(self.as_ref())
}
fn as_collectable_with_default_mut(&mut self) -> &mut dyn Collectable {
todo!()
Events::as_collectable_with_default_mut(self.as_mut())
}
fn ts_min(&self) -> Option<u64> {
todo!()
Events::ts_min(self.as_ref())
}
fn ts_max(&self) -> Option<u64> {
todo!()
Events::ts_max(self.as_ref())
}
fn take_new_events_until_ts(&mut self, ts_end: u64) -> Box<dyn Events> {
todo!()
Events::take_new_events_until_ts(self.as_mut(), ts_end)
}
fn new_empty_evs(&self) -> Box<dyn Events> {
todo!()
Events::new_empty_evs(self.as_ref())
}
fn drain_into_evs(&mut self, dst: &mut Box<dyn Events>, range: (usize, usize)) -> Result<(), MergeError> {
todo!()
Events::drain_into_evs(self.as_mut(), dst, range)
}
fn find_lowest_index_gt_evs(&self, ts: u64) -> Option<usize> {
todo!()
Events::find_lowest_index_gt_evs(self.as_ref(), ts)
}
fn find_lowest_index_ge_evs(&self, ts: u64) -> Option<usize> {
todo!()
Events::find_lowest_index_ge_evs(self.as_ref(), ts)
}
fn find_highest_index_lt_evs(&self, ts: u64) -> Option<usize> {
todo!()
Events::find_highest_index_lt_evs(self.as_ref(), ts)
}
fn clone_dyn(&self) -> Box<dyn Events> {
todo!()
Events::clone_dyn(self.as_ref())
}
fn partial_eq_dyn(&self, other: &dyn Events) -> bool {
todo!()
Events::partial_eq_dyn(self.as_ref(), other)
}
fn serde_id(&self) -> &'static str {
todo!()
Events::serde_id(self.as_ref())
}
fn nty_id(&self) -> u32 {
todo!()
Events::nty_id(self.as_ref())
}
fn tss(&self) -> &VecDeque<u64> {
todo!()
Events::tss(self.as_ref())
}
fn pulses(&self) -> &VecDeque<u64> {
todo!()
Events::pulses(self.as_ref())
}
fn frame_type_id(&self) -> u32 {
Events::frame_type_id(self.as_ref())
}
fn to_min_max_avg(&mut self) -> Box<dyn Events> {
Events::to_min_max_avg(self.as_mut())
}
}

View File

@@ -9,7 +9,10 @@ use err::Error;
use futures_util::stream;
use futures_util::Future;
use futures_util::Stream;
use futures_util::StreamExt;
use std::pin::Pin;
use std::task::Context;
use std::task::Poll;
pub trait EventStreamTrait: Stream<Item = Sitemty<Box<dyn Events>>> + WithTransformProperties + Send {}
@@ -23,6 +26,10 @@ pub trait CollectableStreamTrait:
{
}
pub struct EventTransformProperties {
pub needs_value: bool,
}
pub struct TransformProperties {
pub needs_one_before_range: bool,
pub needs_value: bool,
@@ -50,7 +57,7 @@ where
}
}
pub trait EventTransform: WithTransformProperties {
pub trait EventTransform: WithTransformProperties + Send {
fn transform(&mut self, src: Box<dyn Events>) -> Box<dyn Events>;
}
@@ -130,6 +137,24 @@ where
}
}
pub struct TimeBinnableStreamBox(pub Pin<Box<dyn TimeBinnableStreamTrait>>);
impl WithTransformProperties for TimeBinnableStreamBox {
fn query_transform_properties(&self) -> TransformProperties {
self.0.query_transform_properties()
}
}
impl Stream for TimeBinnableStreamBox {
type Item = <dyn TimeBinnableStreamTrait as Stream>::Item;
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
self.0.poll_next_unpin(cx)
}
}
impl TimeBinnableStreamTrait for TimeBinnableStreamBox {}
pub struct CollectableStreamBox(pub Pin<Box<dyn CollectableStreamTrait>>);
impl<T> WithTransformProperties for stream::Empty<T> {