mod change_log;
mod deq_column;
pub(crate) mod lod;
pub(crate) mod ohlc;
mod time_index;
pub(crate) mod value;
pub use change_log::{ChangeLog, DataDelta};
pub use deq_column::DeqColumn;
pub use lod::{ANCHOR, MIN_LOD_LEVEL};
pub use ohlc::{BarUpdate, Column, DataChange, OhlcLevelView, ValidationMode};
pub use time_index::{SeriesMapping, TimeIndex};
pub type Timestamp = i64;
pub type LogicalIndex = f64;
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub struct SeriesId(pub u32);
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub struct IndicatorId(pub u32);
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub struct PriceLineId(pub u32);
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub struct BandId(pub u32);
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub struct LayerPluginId(pub u32);
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub struct PaneId(pub u32);
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub struct DrawingId(pub u64);
#[derive(Clone, Debug, Default, PartialEq)]
pub struct ValueColumns {
pub time: Vec<Timestamp>,
pub value: Vec<f64>,
pub color: Option<Vec<u32>>,
}
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default, Hash)]
pub struct IdxSpan {
pub start: i64,
pub end: i64,
}
impl IdxSpan {
pub fn is_empty(self) -> bool {
self.end <= self.start
}
pub fn len(self) -> u64 {
self.end.abs_diff(self.start) * u64::from(self.end > self.start)
}
pub(crate) fn touches(self, other: Self) -> bool {
other.start <= self.end && self.start <= other.end
}
pub(crate) fn hull(self, other: Self) -> Self {
Self {
start: self.start.min(other.start),
end: self.end.max(other.end),
}
}
}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct OhlcColumns {
pub time: Vec<Timestamp>,
pub open: Vec<f64>,
pub high: Vec<f64>,
pub low: Vec<f64>,
pub close: Vec<f64>,
pub volume: Option<Vec<f64>>,
}
impl OhlcColumns {
pub fn len(&self) -> usize {
self.time.len()
}
pub fn is_empty(&self) -> bool {
self.time.is_empty()
}
}