From 6138e4b2b37b11629567406e9d14c7db338982a7 Mon Sep 17 00:00:00 2001 From: GW_MC <72297530+GWMCwing@users.noreply.github.com> Date: Thu, 13 Nov 2025 20:34:29 +0800 Subject: [PATCH] Add missing shared library --- Cargo.toml | 1 + public/shared/Cargo.toml | 10 ++++++++++ public/shared/src/db_type.rs | 28 ++++++++++++++++++++++++++++ public/shared/src/lib.rs | 1 + 4 files changed, 40 insertions(+) create mode 100644 public/shared/Cargo.toml create mode 100644 public/shared/src/db_type.rs create mode 100644 public/shared/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index ac5143a..9c714f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [workspace] members = [ "apps/container", + "apps/shared", "public/database", "public/migration" ] diff --git a/public/shared/Cargo.toml b/public/shared/Cargo.toml new file mode 100644 index 0000000..fe6cd4b --- /dev/null +++ b/public/shared/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "shared" +version = "0.1.0" +edition = "2024" + +[lib] +path = "src/lib.rs" + +[lints] +workspace = true diff --git a/public/shared/src/db_type.rs b/public/shared/src/db_type.rs new file mode 100644 index 0000000..b106f86 --- /dev/null +++ b/public/shared/src/db_type.rs @@ -0,0 +1,28 @@ +use std::str::FromStr; + +#[derive(Debug, Clone)] +pub enum DBType { + PostgreSQL, + SQLite, +} + +impl std::fmt::Display for DBType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + DBType::PostgreSQL => write!(f, "PostgreSQL"), + DBType::SQLite => write!(f, "SQLite"), + } + } +} + +impl FromStr for DBType { + type Err = String; + + fn from_str(s: &str) -> Result { + match s.to_lowercase().as_str() { + "postgresql" | "postgres" => Ok(DBType::PostgreSQL), + "sqlite" => Ok(DBType::SQLite), + _ => Err(format!("Unknown DBType: {}", s)), + } + } +} diff --git a/public/shared/src/lib.rs b/public/shared/src/lib.rs new file mode 100644 index 0000000..890fdfa --- /dev/null +++ b/public/shared/src/lib.rs @@ -0,0 +1 @@ +pub mod db_type;