refactor(core): WallClockStore trait replaces the store_mut backdoor
Task 10b reached LogStore::set_wall_clock through a general Node::store_mut. Kyle: replace it with a narrower accessor. A WallClockStore trait (set_wall_clock + peer_time_estimate, implemented only by LogStore) now backs Node::set_wall_clock and Node::peer_time_estimate, so no &mut Store escapes the facade.
This commit is contained in:
+13
-1
@@ -88,7 +88,7 @@ use std::io::Write;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tines_core::{Observation, ObservationId, Store, StoreError, Tick, TrimPolicy};
|
||||
use tines_core::{Observation, ObservationId, Store, StoreError, Tick, TrimPolicy, WallClockStore};
|
||||
|
||||
mod crc32c {
|
||||
//! A minimal, std-only CRC-32C (Castagnoli).
|
||||
@@ -802,6 +802,18 @@ impl LogStore {
|
||||
}
|
||||
}
|
||||
|
||||
impl WallClockStore for LogStore {
|
||||
type FoldReport = FoldReport;
|
||||
|
||||
fn set_wall_clock(&mut self, wall_now: u64, now: Tick) -> FoldReport {
|
||||
LogStore::set_wall_clock(self, wall_now, now)
|
||||
}
|
||||
|
||||
fn peer_time_estimate(&self, now: Tick) -> Option<u64> {
|
||||
LogStore::peer_time_estimate(self, now)
|
||||
}
|
||||
}
|
||||
|
||||
/// Write the log header: `magic ‖ format_version ‖ reserved`.
|
||||
fn write_header(file: &mut File) -> Result<(), StoreError> {
|
||||
file.write_all(&MAGIC).map_err(|_| StoreError::Backend)?;
|
||||
|
||||
Reference in New Issue
Block a user