1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use crate::clocksync::ClockSyncer;
use std::borrow::Borrow;
#[derive(Debug)]
pub struct SyncingClock<ClockSyncerRefType>(ClockSyncerRefType)
where
ClockSyncerRefType: Borrow<ClockSyncer>;
impl<'a> From<&'a ClockSyncer> for SyncingClock<&'a ClockSyncer> {
fn from(clocksyncer: &'a ClockSyncer) -> Self {
Self(clocksyncer)
}
}
impl<'a> From<&'a mut ClockSyncer> for SyncingClock<&'a mut ClockSyncer> {
fn from(clocksyncer: &'a mut ClockSyncer) -> Self {
Self(clocksyncer)
}
}
impl<ClockSyncerRefType> SyncingClock<ClockSyncerRefType>
where
ClockSyncerRefType: Borrow<ClockSyncer>,
{
pub fn sample_count(&self) -> usize {
self.0.borrow().sample_count()
}
pub fn samples_needed(&self) -> usize {
self.0.borrow().samples_needed()
}
}