|
1 | 1 | use std::collections::BTreeMap; |
| 2 | +use std::fmt::Debug; |
2 | 3 | use std::path::{Path, PathBuf}; |
3 | 4 | use std::pin::Pin; |
4 | 5 | use std::str::FromStr; |
@@ -60,13 +61,23 @@ pub enum RestoreOptions { |
60 | 61 | /// map.range(format!("{:020}", u64::MAX - 101)..).next(); |
61 | 62 | /// map.range(format!("{:020}", u64::MAX - 5000)..).next(); |
62 | 63 | /// ``` |
63 | | -#[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 64 | +#[derive(Clone, Copy, PartialEq, Eq)] |
64 | 65 | pub struct SegmentKey { |
65 | 66 | pub start_frame_no: u64, |
66 | 67 | pub end_frame_no: u64, |
67 | 68 | pub timestamp: u64, |
68 | 69 | } |
69 | 70 |
|
| 71 | +impl Debug for SegmentKey { |
| 72 | + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 73 | + f.debug_struct("SegmentKey") |
| 74 | + .field("start_frame_no", &self.start_frame_no) |
| 75 | + .field("end_frame_no", &self.end_frame_no) |
| 76 | + .field("timestamp", &self.timestamp()) |
| 77 | + .finish() |
| 78 | + } |
| 79 | +} |
| 80 | + |
70 | 81 | impl PartialOrd for SegmentKey { |
71 | 82 | fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { |
72 | 83 | match self.start_frame_no.partial_cmp(&other.start_frame_no) { |
@@ -109,6 +120,12 @@ impl SegmentKey { |
109 | 120 |
|
110 | 121 | Some(key) |
111 | 122 | } |
| 123 | + |
| 124 | + fn timestamp(&self) -> DateTime<Utc> { |
| 125 | + DateTime::from_timestamp_millis(self.timestamp as _) |
| 126 | + .unwrap() |
| 127 | + .to_utc() |
| 128 | + } |
112 | 129 | } |
113 | 130 |
|
114 | 131 | impl From<&SegmentMeta> for SegmentKey { |
@@ -629,9 +646,9 @@ pub struct StoreSegmentRequest<S, C> { |
629 | 646 | on_store_callback: OnStoreCallback, |
630 | 647 | } |
631 | 648 |
|
632 | | -impl<S, C> fmt::Debug for StoreSegmentRequest<S, C> |
| 649 | +impl<S, C> Debug for StoreSegmentRequest<S, C> |
633 | 650 | where |
634 | | - S: fmt::Debug, |
| 651 | + S: Debug, |
635 | 652 | { |
636 | 653 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
637 | 654 | f.debug_struct("StoreSegmentRequest") |
|
0 commit comments