#[serde(transparent)]
pub struct Html (pub String);
+#[derive(Copy,Clone,Debug,Serialize,Deserialize,Eq,Ord,PartialEq,PartialOrd)]
+#[serde(transparent)]
+pub struct Timestamp(pub u64); /* time_t */
+
pub const DEFAULT_TABLE_SIZE : Pos = PosC([ 400, 200 ]);
// ---------- general data types ----------
pub pieces : Pieces,
pub players : PlayerMap,
pub gen : Generation,
- pub log : Vec<(Generation,Arc<LogEntry>)>, // xxx expiry
+ pub log : Vec<(Generation, Timestamp, Arc<LogEntry>)>, // xxx expiry
pub max_z : ZCoord,
}
}
}
+impl Timestamp {
+ /// Always >= previously
+ pub fn now() -> Timestamp {
+ use std::time::SystemTime;
+ let now = SystemTime::now()
+ .duration_since(SystemTime::UNIX_EPOCH)
+ .unwrap()
+ .as_secs();
+ Timestamp(now)
+ }
+}
+
pub trait ClampTable : Sized {
fn clamped(self, range: Self) -> (Self, bool);
}
defs : Vec<(VisiblePieceId,Html)>,
nick : String,
load : String,
- log : Vec<(Generation,Arc<LogEntry>)>,
+ log : Vec<(Generation, Timestamp, Arc<LogEntry>)>,
}
#[derive(Serialize,Debug)]
for logentry in logents {
let logentry = Arc::new(logentry);
let gen = self.gen();
- self.g.gs.log.push((gen, logentry.clone()));
+ let now = Timestamp::now();
+ let when = iter::once(now).chain(
+ self.g.gs.log.last().map(|l| l.1)
+ ).max().unwrap();
+ self.g.gs.log.push((gen, when, logentry.clone()));
self.us.push(PreparedUpdateEntry::Log(logentry));
}
}