Add handler for accounting and refactor
This commit is contained in:
37
crates/items_2/src/accounting.rs
Normal file
37
crates/items_2/src/accounting.rs
Normal file
@@ -0,0 +1,37 @@
|
||||
use items_0::Empty;
|
||||
use items_0::Extendable;
|
||||
use items_0::WithLen;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct AccountingEvents {
|
||||
pub tss: VecDeque<u64>,
|
||||
pub bytes: VecDeque<u64>,
|
||||
}
|
||||
|
||||
impl Empty for AccountingEvents {
|
||||
fn empty() -> Self {
|
||||
Self {
|
||||
tss: VecDeque::new(),
|
||||
bytes: VecDeque::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl WithLen for AccountingEvents {
|
||||
fn len(&self) -> usize {
|
||||
self.tss.len()
|
||||
}
|
||||
}
|
||||
|
||||
impl Extendable for AccountingEvents {
|
||||
fn extend_from(&mut self, src: &mut Self) {
|
||||
use core::mem::replace;
|
||||
let v = replace(&mut src.tss, VecDeque::new());
|
||||
self.tss.extend(v.into_iter());
|
||||
let v = replace(&mut src.bytes, VecDeque::new());
|
||||
self.bytes.extend(v.into_iter());
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
pub mod accounting;
|
||||
pub mod binnedcollected;
|
||||
pub mod binsdim0;
|
||||
pub mod binsxbindim0;
|
||||
|
||||
Reference in New Issue
Block a user