Add missing shared library

This commit is contained in:
GW_MC
2025-11-13 20:34:29 +08:00
parent 25c0756e70
commit 6138e4b2b3
4 changed files with 40 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
[workspace] [workspace]
members = [ members = [
"apps/container", "apps/container",
"apps/shared",
"public/database", "public/database",
"public/migration" "public/migration"
] ]

10
public/shared/Cargo.toml Normal file
View File

@@ -0,0 +1,10 @@
[package]
name = "shared"
version = "0.1.0"
edition = "2024"
[lib]
path = "src/lib.rs"
[lints]
workspace = true

View File

@@ -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<Self, Self::Err> {
match s.to_lowercase().as_str() {
"postgresql" | "postgres" => Ok(DBType::PostgreSQL),
"sqlite" => Ok(DBType::SQLite),
_ => Err(format!("Unknown DBType: {}", s)),
}
}
}

1
public/shared/src/lib.rs Normal file
View File

@@ -0,0 +1 @@
pub mod db_type;