places/history_sync/
mod.rsuse serde_derive::*;
use std::fmt;
use std::time::{SystemTime, UNIX_EPOCH};
use types::Timestamp;
pub mod engine;
#[cfg(test)]
mod payload_evolution_tests;
mod plan;
pub mod record;
pub use engine::HistorySyncEngine;
const MAX_INCOMING_PLACES: usize = 5000;
const MAX_OUTGOING_PLACES: usize = 5000;
const MAX_VISITS: usize = 20;
pub const HISTORY_TTL: u32 = 5_184_000; #[derive(
Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Deserialize, Serialize, Default,
)]
pub struct ServerVisitTimestamp(pub u64);
impl From<ServerVisitTimestamp> for Timestamp {
#[inline]
fn from(ts: ServerVisitTimestamp) -> Timestamp {
Timestamp(ts.0 / 1000)
}
}
impl From<Timestamp> for ServerVisitTimestamp {
#[inline]
fn from(ts: Timestamp) -> ServerVisitTimestamp {
ServerVisitTimestamp(ts.0 * 1000)
}
}
impl From<SystemTime> for ServerVisitTimestamp {
#[inline]
fn from(st: SystemTime) -> Self {
let d = st.duration_since(UNIX_EPOCH).unwrap_or_default();
ServerVisitTimestamp(d.as_secs() * 1_000_000 + (u64::from(d.subsec_nanos()) / 1_000))
}
}
impl fmt::Display for ServerVisitTimestamp {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}