wire types: WireTime newtype for timestamps instead of adaptor-annotated i64
This commit is contained in:
parent
cf1f7288bf
commit
1e205289c5
12 changed files with 148 additions and 162 deletions
|
|
@ -14,6 +14,7 @@ use std::sync::Mutex;
|
|||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
use anyhow::{Context, Result, bail};
|
||||
use hive_sh4re::wire_time::WireTime;
|
||||
use rusqlite::{Connection, OptionalExtension, params};
|
||||
use serde::Serialize;
|
||||
|
||||
|
|
@ -74,15 +75,12 @@ pub struct OpQuestion {
|
|||
pub question: String,
|
||||
pub options: Vec<String>,
|
||||
pub multi: bool,
|
||||
#[serde(with = "hive_sh4re::wire_time::iso")]
|
||||
pub asked_at: i64,
|
||||
pub asked_at: WireTime,
|
||||
/// Deadline after which a watchdog auto-resolves the question with
|
||||
/// answer `[expired]`. `None` = no expiry. Surfaced on the
|
||||
/// dashboard as a remaining-time chip.
|
||||
#[serde(with = "hive_sh4re::wire_time::iso_opt")]
|
||||
pub deadline_at: Option<i64>,
|
||||
#[serde(with = "hive_sh4re::wire_time::iso_opt")]
|
||||
pub answered_at: Option<i64>,
|
||||
pub deadline_at: Option<WireTime>,
|
||||
pub answered_at: Option<WireTime>,
|
||||
pub answer: Option<String>,
|
||||
/// Recipient of the question. `None` = the operator (dashboard
|
||||
/// path); `Some(<agent>)` = a peer agent asked via
|
||||
|
|
@ -290,10 +288,14 @@ fn row_to_question(row: &rusqlite::Row<'_>) -> rusqlite::Result<OpQuestion> {
|
|||
question: row.get(2)?,
|
||||
options,
|
||||
multi: multi != 0,
|
||||
asked_at: row.get(5)?,
|
||||
answered_at: row.get(6)?,
|
||||
asked_at: hive_sh4re::wire_time::WireTime(row.get(5)?),
|
||||
answered_at: row
|
||||
.get::<_, Option<i64>>(6)?
|
||||
.map(hive_sh4re::wire_time::WireTime),
|
||||
answer: row.get(7)?,
|
||||
deadline_at: row.get(8)?,
|
||||
deadline_at: row
|
||||
.get::<_, Option<i64>>(8)?
|
||||
.map(hive_sh4re::wire_time::WireTime),
|
||||
target: row.get(9)?,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue