1use crate::prelude::*;
2
3#[derive(Debug, Encode, Decode, Clone)]
4pub struct InfoKey {
5 pub repo: crate::db::CacheRepo,
6 #[musli(with = musli::serde)]
7 pub config: crate::db::RepoConfig,
8}
9
10impl InfoKey {
11 pub fn user_repo(&self) -> [&str; 2] {
12 self.repo.user_repo()
13 }
14}
15
16redb_value!(@key InfoKey, name: "OsCheckerInfoKey",
17 read_err: "Not a valid info key.",
18 write_err: "Info key can't be encoded to bytes."
19);
20
21#[derive(Debug, Encode, Decode)]
22pub struct Info {
23 pub complete: bool,
25 pub caches: Vec<crate::db::CacheRepoKey>,
27 pub latest_commit: LatestCommit,
29}
30
31redb_value!(Info, name: "OsCheckerInfo",
32 read_err: "Not a valid info value.",
33 write_err: "Info value can't be encoded to bytes."
34);
35
36#[derive(Debug, Encode, Decode)]
37pub struct LatestCommit {
38 pub sha: String,
39 pub mes: String,
40 pub author: Committer,
41 pub committer: Committer,
42}
43
44#[derive(Encode, Decode)]
45pub struct Committer {
46 pub datetime: u64,
48 #[musli(with = musli::serde)]
49 pub email: String,
50 #[musli(with = musli::serde)]
51 pub name: XString,
52}
53
54impl fmt::Debug for Committer {
55 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
56 f.debug_struct("Committer")
57 .field(
58 "datetime",
59 &super::parse_unix_timestamp_milli(self.datetime),
60 )
61 .field("email", &self.email)
62 .field("name", &self.name)
63 .finish()
64 }
65}
66
67