Clean unused
This commit is contained in:
+1
-33
@@ -1,14 +1,12 @@
|
||||
use crate::apitypes::ToUserFacingApiType;
|
||||
use crate::container::ByteEstimate;
|
||||
use crate::timebin::BinningggContainerBinsDyn;
|
||||
use crate::log::*;
|
||||
use crate::AsAnyMut;
|
||||
use crate::AsAnyRef;
|
||||
use crate::Events;
|
||||
use crate::TypeName;
|
||||
use crate::WithLen;
|
||||
use daqbuf_err as err;
|
||||
use err::Error;
|
||||
use netpod::log::*;
|
||||
use std::any;
|
||||
use std::any::Any;
|
||||
use std::fmt;
|
||||
@@ -123,36 +121,6 @@ pub trait CollectableDyn: fmt::Debug + WithLen + AsAnyRef + AsAnyMut + Send + Ty
|
||||
fn new_collector(&self) -> Box<dyn CollectorDyn>;
|
||||
}
|
||||
|
||||
impl TypeName for Box<dyn BinningggContainerBinsDyn> {
|
||||
fn type_name(&self) -> String {
|
||||
self.as_ref().type_name()
|
||||
}
|
||||
}
|
||||
|
||||
impl WithLen for Box<dyn BinningggContainerBinsDyn> {
|
||||
fn len(&self) -> usize {
|
||||
WithLen::len(self.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
impl CollectableDyn for Box<dyn BinningggContainerBinsDyn> {
|
||||
fn new_collector(&self) -> Box<dyn CollectorDyn> {
|
||||
self.as_ref().new_collector()
|
||||
}
|
||||
}
|
||||
|
||||
impl TypeName for Box<dyn Events> {
|
||||
fn type_name(&self) -> String {
|
||||
self.as_ref().type_name()
|
||||
}
|
||||
}
|
||||
|
||||
impl CollectableDyn for Box<dyn Events> {
|
||||
fn new_collector(&self) -> Box<dyn CollectorDyn> {
|
||||
self.as_ref().new_collector()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> CollectableDyn for T
|
||||
where
|
||||
T: CollectableType + 'static,
|
||||
|
||||
@@ -1,20 +1,3 @@
|
||||
use crate::Events;
|
||||
|
||||
pub trait ByteEstimate {
|
||||
fn byte_estimate(&self) -> u64;
|
||||
}
|
||||
|
||||
impl ByteEstimate for Box<dyn Events> {
|
||||
fn byte_estimate(&self) -> u64 {
|
||||
self.as_ref().byte_estimate()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ByteEstimate for Box<T>
|
||||
where
|
||||
T: ByteEstimate,
|
||||
{
|
||||
fn byte_estimate(&self) -> u64 {
|
||||
self.as_ref().byte_estimate()
|
||||
}
|
||||
}
|
||||
|
||||
-207
@@ -1,13 +1,7 @@
|
||||
pub use futures_util;
|
||||
|
||||
use crate::collect_s::CollectableDyn;
|
||||
use crate::container::ByteEstimate;
|
||||
use crate::timebin::BinningggContainerEventsDyn;
|
||||
use daqbuf_err as err;
|
||||
use netpod::TsNano;
|
||||
use std::any::Any;
|
||||
use std::collections::VecDeque;
|
||||
use std::fmt;
|
||||
|
||||
pub trait WithLen {
|
||||
fn len(&self) -> usize;
|
||||
@@ -48,20 +42,6 @@ pub trait TypeName {
|
||||
fn type_name(&self) -> String;
|
||||
}
|
||||
|
||||
pub trait AppendEmptyBin {
|
||||
fn append_empty_bin(&mut self, ts1: u64, ts2: u64);
|
||||
}
|
||||
|
||||
// TODO rename to make it clear that this moves. Better use drain-into or something similar.
|
||||
pub trait AppendAllFrom {
|
||||
fn append_all_from(&mut self, src: &mut Self);
|
||||
}
|
||||
|
||||
// TODO check usage, probably only for legacy
|
||||
pub trait HasNonemptyFirstBin {
|
||||
fn has_nonempty_first_bin(&self) -> bool;
|
||||
}
|
||||
|
||||
pub trait AsAnyRef {
|
||||
fn as_any_ref(&self) -> &dyn Any;
|
||||
}
|
||||
@@ -87,190 +67,3 @@ where
|
||||
self.as_mut().as_any_mut()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO can I remove the Any bound?
|
||||
|
||||
/// Container of some form of events, for use as trait object.
|
||||
pub trait Events:
|
||||
fmt::Debug
|
||||
+ TypeName
|
||||
+ Any
|
||||
+ CollectableDyn
|
||||
+ WithLen
|
||||
+ ByteEstimate
|
||||
+ Send
|
||||
+ erased_serde::Serialize
|
||||
+ EventsNonObj
|
||||
{
|
||||
fn verify(&self) -> bool;
|
||||
fn output_info(&self) -> String;
|
||||
fn as_collectable_mut(&mut self) -> &mut dyn CollectableDyn;
|
||||
fn as_collectable_with_default_ref(&self) -> &dyn CollectableDyn;
|
||||
fn as_collectable_with_default_mut(&mut self) -> &mut dyn CollectableDyn;
|
||||
fn ts_min(&self) -> Option<u64>;
|
||||
fn ts_max(&self) -> Option<u64>;
|
||||
// TODO is this used?
|
||||
fn take_new_events_until_ts(&mut self, ts_end: u64) -> Box<dyn Events>;
|
||||
fn new_empty_evs(&self) -> Box<dyn Events>;
|
||||
fn drain_into_evs(
|
||||
&mut self,
|
||||
dst: &mut dyn Events,
|
||||
range: (usize, usize),
|
||||
) -> Result<(), err::Error>;
|
||||
fn find_lowest_index_gt_evs(&self, ts: u64) -> Option<usize>;
|
||||
fn find_lowest_index_ge_evs(&self, ts: u64) -> Option<usize>;
|
||||
fn find_highest_index_lt_evs(&self, ts: u64) -> Option<usize>;
|
||||
fn clone_dyn(&self) -> Box<dyn Events>;
|
||||
fn partial_eq_dyn(&self, other: &dyn Events) -> bool;
|
||||
fn serde_id(&self) -> &'static str;
|
||||
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>;
|
||||
fn to_json_string(&self) -> String;
|
||||
fn to_json_vec_u8(&self) -> Vec<u8>;
|
||||
fn to_cbor_vec_u8(&self) -> Vec<u8>;
|
||||
fn clear(&mut self);
|
||||
// TODO: can not name EventsDim0 from here, so use trait object for now. Anyway is a workaround.
|
||||
fn to_dim0_f32_for_binning(&self) -> Box<dyn Events>;
|
||||
fn to_container_events(&self) -> Box<dyn BinningggContainerEventsDyn>;
|
||||
}
|
||||
|
||||
impl WithLen for Box<dyn Events> {
|
||||
fn len(&self) -> usize {
|
||||
self.as_ref().len()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait EventsNonObj {
|
||||
fn into_tss_pulses(self: Box<Self>) -> (VecDeque<u64>, VecDeque<u64>);
|
||||
}
|
||||
|
||||
erased_serde::serialize_trait_object!(Events);
|
||||
|
||||
impl PartialEq for Box<dyn Events> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
Events::partial_eq_dyn(self.as_ref(), other.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
impl EventsNonObj for Box<dyn Events> {
|
||||
fn into_tss_pulses(self: Box<Self>) -> (VecDeque<u64>, VecDeque<u64>) {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Events for Box<dyn Events> {
|
||||
fn verify(&self) -> bool {
|
||||
Events::verify(self.as_ref())
|
||||
}
|
||||
|
||||
fn output_info(&self) -> String {
|
||||
Events::output_info(self.as_ref())
|
||||
}
|
||||
|
||||
fn as_collectable_mut(&mut self) -> &mut dyn CollectableDyn {
|
||||
Events::as_collectable_mut(self.as_mut())
|
||||
}
|
||||
|
||||
fn as_collectable_with_default_ref(&self) -> &dyn CollectableDyn {
|
||||
Events::as_collectable_with_default_ref(self.as_ref())
|
||||
}
|
||||
|
||||
fn as_collectable_with_default_mut(&mut self) -> &mut dyn CollectableDyn {
|
||||
Events::as_collectable_with_default_mut(self.as_mut())
|
||||
}
|
||||
|
||||
fn ts_min(&self) -> Option<u64> {
|
||||
Events::ts_min(self.as_ref())
|
||||
}
|
||||
|
||||
fn ts_max(&self) -> Option<u64> {
|
||||
Events::ts_max(self.as_ref())
|
||||
}
|
||||
|
||||
fn take_new_events_until_ts(&mut self, ts_end: u64) -> Box<dyn Events> {
|
||||
Events::take_new_events_until_ts(self.as_mut(), ts_end)
|
||||
}
|
||||
|
||||
fn new_empty_evs(&self) -> Box<dyn Events> {
|
||||
Events::new_empty_evs(self.as_ref())
|
||||
}
|
||||
|
||||
fn drain_into_evs(
|
||||
&mut self,
|
||||
dst: &mut dyn Events,
|
||||
range: (usize, usize),
|
||||
) -> Result<(), err::Error> {
|
||||
Events::drain_into_evs(self.as_mut(), dst, range)
|
||||
}
|
||||
|
||||
fn find_lowest_index_gt_evs(&self, ts: u64) -> Option<usize> {
|
||||
Events::find_lowest_index_gt_evs(self.as_ref(), ts)
|
||||
}
|
||||
|
||||
fn find_lowest_index_ge_evs(&self, ts: u64) -> Option<usize> {
|
||||
Events::find_lowest_index_ge_evs(self.as_ref(), ts)
|
||||
}
|
||||
|
||||
fn find_highest_index_lt_evs(&self, ts: u64) -> Option<usize> {
|
||||
Events::find_highest_index_lt_evs(self.as_ref(), ts)
|
||||
}
|
||||
|
||||
fn clone_dyn(&self) -> Box<dyn Events> {
|
||||
Events::clone_dyn(self.as_ref())
|
||||
}
|
||||
|
||||
fn partial_eq_dyn(&self, other: &dyn Events) -> bool {
|
||||
Events::partial_eq_dyn(self.as_ref(), other)
|
||||
}
|
||||
|
||||
fn serde_id(&self) -> &'static str {
|
||||
Events::serde_id(self.as_ref())
|
||||
}
|
||||
|
||||
fn nty_id(&self) -> u32 {
|
||||
Events::nty_id(self.as_ref())
|
||||
}
|
||||
|
||||
fn tss(&self) -> &VecDeque<u64> {
|
||||
Events::tss(self.as_ref())
|
||||
}
|
||||
|
||||
fn pulses(&self) -> &VecDeque<u64> {
|
||||
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())
|
||||
}
|
||||
|
||||
fn to_json_string(&self) -> String {
|
||||
Events::to_json_string(self.as_ref())
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
|
||||
fn clear(&mut self) {
|
||||
Events::clear(self.as_mut())
|
||||
}
|
||||
|
||||
fn to_dim0_f32_for_binning(&self) -> Box<dyn Events> {
|
||||
Events::to_dim0_f32_for_binning(self.as_ref())
|
||||
}
|
||||
|
||||
fn to_container_events(&self) -> Box<dyn BinningggContainerEventsDyn> {
|
||||
Events::to_container_events(self.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -11,9 +11,15 @@ pub mod streamitem;
|
||||
pub mod subfr;
|
||||
pub mod test;
|
||||
pub mod timebin;
|
||||
pub mod transform;
|
||||
pub mod vecpreview;
|
||||
|
||||
mod log {
|
||||
#[cfg(not(test))]
|
||||
pub use netpod::log::*;
|
||||
#[cfg(test)]
|
||||
pub use netpod::log_direct::*;
|
||||
}
|
||||
|
||||
pub mod bincode {
|
||||
pub use bincode::*;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
use crate::apitypes::ToUserFacingApiType;
|
||||
use crate::collect_s::CollectableDyn;
|
||||
use crate::container::ByteEstimate;
|
||||
use crate::merge::DrainIntoDstResult;
|
||||
use crate::merge::DrainIntoNewDynResult;
|
||||
use crate::merge::MergeableDyn;
|
||||
use crate::AsAnyMut;
|
||||
use crate::AsAnyRef;
|
||||
@@ -11,7 +9,6 @@ use crate::WithLen;
|
||||
use netpod::BinnedRange;
|
||||
use netpod::BinnedRangeEnum;
|
||||
use netpod::TsNano;
|
||||
use std::collections::VecDeque;
|
||||
use std::fmt;
|
||||
use std::ops::Range;
|
||||
|
||||
@@ -111,51 +108,6 @@ pub trait BinningggContainerEventsDyn:
|
||||
fn as_collectable_dyn_mut(&mut self) -> &mut dyn CollectableDyn;
|
||||
}
|
||||
|
||||
impl<T> MergeableDyn for Box<T>
|
||||
where
|
||||
T: MergeableDyn,
|
||||
{
|
||||
fn ts_min(&self) -> Option<TsNano> {
|
||||
self.as_ref().ts_min()
|
||||
}
|
||||
|
||||
fn ts_max(&self) -> Option<TsNano> {
|
||||
self.as_ref().ts_max()
|
||||
}
|
||||
|
||||
fn find_lowest_index_gt(&self, ts: TsNano) -> Option<usize> {
|
||||
self.as_ref().find_lowest_index_gt(ts)
|
||||
}
|
||||
|
||||
fn find_lowest_index_ge(&self, ts: TsNano) -> Option<usize> {
|
||||
self.as_ref().find_lowest_index_ge(ts)
|
||||
}
|
||||
|
||||
fn find_highest_index_lt(&self, ts: TsNano) -> Option<usize> {
|
||||
self.as_ref().find_highest_index_lt(ts)
|
||||
}
|
||||
|
||||
fn tss_for_testing(&self) -> VecDeque<TsNano> {
|
||||
self.as_ref().tss_for_testing()
|
||||
}
|
||||
|
||||
fn drain_into(
|
||||
&mut self,
|
||||
dst: &mut dyn MergeableDyn,
|
||||
range: Range<usize>,
|
||||
) -> DrainIntoDstResult {
|
||||
self.as_mut().drain_into(dst, range)
|
||||
}
|
||||
|
||||
fn drain_into_new(&mut self, range: Range<usize>) -> DrainIntoNewDynResult {
|
||||
self.as_mut().drain_into_new(range)
|
||||
}
|
||||
|
||||
fn is_consistent(&self) -> bool {
|
||||
self.as_ref().is_consistent()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait BinningggContainerBinsDyn:
|
||||
fmt::Debug + Send + fmt::Display + TypeName + WithLen + AsAnyMut + CollectableDyn
|
||||
{
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
use crate::collect_s::CollectableDyn;
|
||||
use crate::streamitem::RangeCompletableItem;
|
||||
use crate::streamitem::Sitemty;
|
||||
use crate::streamitem::StreamItem;
|
||||
use crate::Events;
|
||||
use futures_util::stream;
|
||||
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
|
||||
{
|
||||
}
|
||||
|
||||
pub trait CollectableStreamTrait:
|
||||
Stream<Item = Sitemty<Box<dyn CollectableDyn>>> + WithTransformProperties + Send
|
||||
{
|
||||
}
|
||||
|
||||
pub struct EventTransformProperties {
|
||||
pub needs_value: bool,
|
||||
}
|
||||
|
||||
pub struct TransformProperties {
|
||||
pub needs_one_before_range: bool,
|
||||
pub needs_value: bool,
|
||||
}
|
||||
|
||||
pub trait WithTransformProperties {
|
||||
fn query_transform_properties(&self) -> TransformProperties;
|
||||
}
|
||||
|
||||
impl<T> WithTransformProperties for Box<T>
|
||||
where
|
||||
T: WithTransformProperties,
|
||||
{
|
||||
fn query_transform_properties(&self) -> TransformProperties {
|
||||
self.as_ref().query_transform_properties()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> WithTransformProperties for Pin<Box<T>>
|
||||
where
|
||||
T: WithTransformProperties,
|
||||
{
|
||||
fn query_transform_properties(&self) -> TransformProperties {
|
||||
self.as_ref().query_transform_properties()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct IdentityTransform {}
|
||||
|
||||
impl IdentityTransform {
|
||||
pub fn default() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
impl WithTransformProperties for IdentityTransform {
|
||||
fn query_transform_properties(&self) -> TransformProperties {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> WithTransformProperties for stream::Iter<T> {
|
||||
fn query_transform_properties(&self) -> TransformProperties {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> EventStreamTrait for stream::Iter<T> where
|
||||
T: core::iter::Iterator<Item = Sitemty<Box<(dyn Events + 'static)>>> + Send
|
||||
{
|
||||
}
|
||||
|
||||
pub struct EventStreamBox(pub Pin<Box<dyn EventStreamTrait>>);
|
||||
|
||||
impl<T> From<T> for EventStreamBox
|
||||
where
|
||||
T: Events,
|
||||
{
|
||||
fn from(value: T) -> Self {
|
||||
let item = Ok(StreamItem::DataItem(RangeCompletableItem::Data(
|
||||
Box::new(value) as _,
|
||||
)));
|
||||
let x = stream::iter(vec![item]);
|
||||
Self(Box::pin(x))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CollectableStreamBox(pub Pin<Box<dyn CollectableStreamTrait>>);
|
||||
|
||||
impl Stream for CollectableStreamBox {
|
||||
type Item = Sitemty<Box<dyn CollectableDyn>>;
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||
self.0.poll_next_unpin(cx)
|
||||
}
|
||||
}
|
||||
|
||||
impl WithTransformProperties for CollectableStreamBox {
|
||||
fn query_transform_properties(&self) -> TransformProperties {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl CollectableStreamTrait for CollectableStreamBox {}
|
||||
|
||||
impl<T> WithTransformProperties for stream::Empty<T> {
|
||||
fn query_transform_properties(&self) -> TransformProperties {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> CollectableStreamTrait for stream::Empty<T>
|
||||
where
|
||||
T: Send,
|
||||
stream::Empty<T>: Stream<Item = Sitemty<Box<dyn CollectableDyn>>>,
|
||||
{
|
||||
}
|
||||
|
||||
impl<T> CollectableStreamTrait for Pin<Box<T>> where T: CollectableStreamTrait {}
|
||||
Reference in New Issue
Block a user