homestar_runtime/db/
utils.rs1use chrono::{DateTime, NaiveDateTime};
4use schemars::JsonSchema;
5use serde::{Deserialize, Serialize};
6
7#[allow(dead_code)]
9pub(crate) trait Timestamp {
10 fn timestamp_from_nanos(&self) -> Option<NaiveDateTime>;
11}
12
13impl Timestamp for i64 {
14 fn timestamp_from_nanos(&self) -> Option<NaiveDateTime> {
15 let nanos = self % 1_000_000_000;
16 let seconds = (self - nanos) / 1_000_000_000;
17 let dt = DateTime::from_timestamp(seconds, nanos as u32);
18 dt.map(|dt| dt.naive_utc())
19 }
20}
21
22#[derive(Debug, Serialize, Deserialize, JsonSchema)]
24#[schemars(rename = "health")]
25pub struct Health {
26 pub healthy: bool,
28}