wire types: WireTime newtype for timestamps instead of adaptor-annotated i64

This commit is contained in:
damocles 2026-07-03 19:18:33 +02:00 committed by mara
commit 1e205289c5
12 changed files with 148 additions and 162 deletions

View file

@ -24,6 +24,7 @@ use std::sync::{Arc, Mutex, OnceLock};
use std::time::{SystemTime, UNIX_EPOCH};
use anyhow::{Context, Result};
use hive_sh4re::wire_time::WireTime;
use rusqlite::{Connection, params};
use serde::Serialize;
@ -89,8 +90,7 @@ impl AuditOutcome {
#[derive(Debug, Clone, Serialize)]
pub struct AuditEntry {
pub id: i64,
#[serde(with = "hive_sh4re::wire_time::iso")]
pub ts_unix: i64,
pub ts_unix: WireTime,
/// Agent on whose behalf the action was taken.
pub agent: String,
/// What was done (e.g. `restart_infra`).
@ -159,7 +159,7 @@ impl AuditLog {
) {
Ok(_) => Some(AuditEntry {
id: conn.last_insert_rowid(),
ts_unix: now,
ts_unix: hive_sh4re::wire_time::WireTime(now),
agent: agent.to_owned(),
action: action.to_owned(),
target: target.to_owned(),
@ -252,7 +252,7 @@ pub fn spawn_vacuum(coord: &Arc<crate::coordinator::Coordinator>) {
fn row_to_entry(r: &rusqlite::Row) -> rusqlite::Result<AuditEntry> {
Ok(AuditEntry {
id: r.get(0)?,
ts_unix: r.get(1)?,
ts_unix: hive_sh4re::wire_time::WireTime(r.get(1)?),
agent: r.get(2)?,
action: r.get(3)?,
target: r.get(4)?,