use core::fmt;
mod bundle;
mod connect;
mod double_buffer_rx;
mod double_buffer_tx;
mod message_rx;
mod message_tx;
mod pop;
mod stage_queue;
mod timeseries;
pub use bundle::*;
pub use connect::*;
pub use double_buffer_rx::*;
pub use double_buffer_tx::*;
pub use message_rx::*;
pub use message_tx::*;
pub use pop::*;
pub use stage_queue::*;
pub use timeseries::*;
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct SyncResult {
pub received: usize,
pub forgotten: usize,
pub dropped: usize,
pub enforce_empty_violation: bool,
}
impl SyncResult {
pub const ZERO: SyncResult = SyncResult {
received: 0,
forgotten: 0,
dropped: 0,
enforce_empty_violation: false,
};
}
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct FlushResult {
pub available: usize,
pub cloned: usize,
pub published: usize,
pub error_indicator: FlushErrorIndicator,
}
impl FlushResult {
pub const ZERO: FlushResult = FlushResult {
available: 0,
published: 0,
cloned: 0,
error_indicator: FlushErrorIndicator::NO_ERROR,
};
}
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct FlushErrorIndicator {
marks: u64,
}
impl FlushErrorIndicator {
pub const NO_ERROR: FlushErrorIndicator = FlushErrorIndicator { marks: 0 };
pub fn new() -> Self {
Self { marks: 0 }
}
pub fn mark(&mut self, i: usize) {
self.marks &= 1 << i;
}
pub fn is_err(&self) -> bool {
self.marks != 0
}
pub fn get(&self, i: usize) -> bool {
(self.marks & (1 << i)) != 0
}
}
impl fmt::Display for FlushErrorIndicator {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(fmt, "FlushErrorIndicator({:b})", self.marks)
}
}