apple_quant_algorithmic/timestamp/
bin.rs1mod index;
2
3use std::ops::Deref;
4
5use crate::timestamp::{Timestamp, Timestamped, TradeTimestamp};
6
7pub use index::*;
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
10pub struct RuntimeBinTimestamp {
11 pub timestamp: Timestamp,
12 pub ns_len: u64,
13}
14
15#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
16pub struct BinTimestamp<const NS_LEN: u64>(BinIndex<NS_LEN>);
17
18impl<const NS_LEN: u64> From<TradeTimestamp> for BinTimestamp<NS_LEN> {
19 fn from(
20 value: TradeTimestamp,
21 ) -> Self {
22 let bin_index = BinIndex::from_timestamped(value);
23 Self(bin_index)
24 }
25}
26
27impl<const NS_LEN: u64> Deref for BinTimestamp<NS_LEN> {
28 type Target = BinIndex<NS_LEN>;
29
30 fn deref(
31 &self,
32 ) -> &Self::Target {
33 &self.0
34 }
35}
36
37impl<const NS_LEN: u64> Timestamped for BinTimestamp<NS_LEN> {
38 fn timestamp(
39 &self,
40 ) -> Timestamp {
41 self.0.timestamp()
42 }
43}