From a7987876d335139ed23fdd81aaa28f02bb62cd9d Mon Sep 17 00:00:00 2001 From: Carter Green Date: Fri, 17 May 2024 14:36:24 -0500 Subject: [PATCH] ADD: Add missing ts_in_delta method for StatMsg --- CHANGELOG.md | 2 ++ rust/dbn/src/record/methods.rs | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f3ad11..f8bab45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ - Added new `DBNError` Python exception that's now the primary exception raised by `databento_dbn` - Improved async performance of decoding DBN files +- Added `StatMsg::ts_in_delta()` method that returns a `time::Duration` for consistency + with other records with a `ts_in_delta` field ### Breaking changes - Changed type of `flags` in `MboMsg`, `TradeMsg`, `Mbp1Msg`, `Mbp10Msg`, and `CbboMsg` diff --git a/rust/dbn/src/record/methods.rs b/rust/dbn/src/record/methods.rs index ffcd09d..8d77b88 100644 --- a/rust/dbn/src/record/methods.rs +++ b/rust/dbn/src/record/methods.rs @@ -669,6 +669,11 @@ impl StatMsg { Error::conversion::(format!("{:04X}", self.update_action)) }) } + + /// Parses the raw `ts_in_delta`—the delta of `ts_recv - ts_exchange_send`—into a duration. + pub fn ts_in_delta(&self) -> time::Duration { + time::Duration::new(0, self.ts_in_delta) + } } impl ErrorMsgV1 {