From 805723f10dec702f0c8e86900c467b6a97fb5ae4 Mon Sep 17 00:00:00 2001 From: Zynh Ludwig Date: Wed, 20 Nov 2024 23:25:18 -0800 Subject: [PATCH] add db structs --- src/db.rs | 14 ++++++++++++++ src/lib.rs | 1 + 2 files changed, 15 insertions(+) create mode 100644 src/db.rs diff --git a/src/db.rs b/src/db.rs new file mode 100644 index 0000000..1229eab --- /dev/null +++ b/src/db.rs @@ -0,0 +1,14 @@ +use chrono::{DateTime, Utc}; + +pub struct CacheRecord { + pub cache_name: CacheName, + pub uploaded: DateTime, + // This uses i32 because of how sqlx decodes unsigned integers to sqlite + // See: https://docs.rs/sqlx/latest/sqlx/sqlite/types/index.html + pub downloads: i32, + pub max_downloads: i32, +} + +#[derive(sqlx::Type)] +#[sqlx(transparent)] +pub struct CacheName(i32); diff --git a/src/lib.rs b/src/lib.rs index 560d3f5..4874d87 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ pub mod cache; +pub mod db; pub mod router; pub mod state; pub mod util;