Add method to dyn merge
This commit is contained in:
@@ -4,6 +4,7 @@ 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;
|
||||
@@ -35,8 +36,8 @@ pub trait Resettable {
|
||||
fn reset(&mut self);
|
||||
}
|
||||
|
||||
pub trait Appendable<STY>: Empty + WithLen {
|
||||
fn push(&mut self, ts: u64, pulse: u64, value: STY);
|
||||
pub trait Appendable<STY>: WithLen {
|
||||
fn push(&mut self, ts: TsNano, value: STY);
|
||||
}
|
||||
|
||||
pub trait Extendable: Empty + WithLen {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::container::ByteEstimate;
|
||||
use crate::timebin::BinningggContainerEventsDyn;
|
||||
use crate::AsAnyMut;
|
||||
use crate::WithLen;
|
||||
use core::ops::Range;
|
||||
@@ -30,6 +31,13 @@ pub enum DrainIntoNewResult<T> {
|
||||
NotCompatible,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum DrainIntoNewDynResult {
|
||||
Done(Box<dyn BinningggContainerEventsDyn>),
|
||||
Partial(Box<dyn BinningggContainerEventsDyn>),
|
||||
NotCompatible,
|
||||
}
|
||||
|
||||
pub trait MergeableTy: fmt::Debug + WithLen + ByteEstimate + Unpin + Sized {
|
||||
fn ts_min(&self) -> Option<TsNano>;
|
||||
fn ts_max(&self) -> Option<TsNano>;
|
||||
@@ -50,4 +58,5 @@ pub trait MergeableDyn: fmt::Debug + WithLen + ByteEstimate + Unpin + AsAnyMut {
|
||||
fn tss_for_testing(&self) -> Vec<TsMs>;
|
||||
fn drain_into(&mut self, dst: &mut dyn MergeableDyn, range: Range<usize>)
|
||||
-> DrainIntoDstResult;
|
||||
fn drain_into_new(&mut self, range: Range<usize>) -> DrainIntoNewDynResult;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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;
|
||||
@@ -97,6 +98,7 @@ pub trait BinningggContainerEventsDyn:
|
||||
fn serde_id(&self) -> u32;
|
||||
fn nty_id(&self) -> u32;
|
||||
fn eq(&self, rhs: &dyn BinningggContainerEventsDyn) -> bool;
|
||||
fn verify(&self) -> bool;
|
||||
}
|
||||
|
||||
impl<T> MergeableDyn for Box<T>
|
||||
@@ -132,7 +134,11 @@ where
|
||||
dst: &mut dyn MergeableDyn,
|
||||
range: Range<usize>,
|
||||
) -> DrainIntoDstResult {
|
||||
todo!()
|
||||
self.as_mut().drain_into(dst, range)
|
||||
}
|
||||
|
||||
fn drain_into_new(&mut self, range: Range<usize>) -> DrainIntoNewDynResult {
|
||||
self.as_mut().drain_into_new(range)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user