feat: add Tauri v2 Rust backend with PostgreSQL support

Add Rust backend: AppState with connection pool management,
TuskError handling, ConnectionConfig model, and all commands
for connections, schema browsing, query execution, data CRUD,
and CSV/JSON export via sqlx.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-11 19:06:27 +03:00
parent 27bdbf0112
commit 9b675babd5
36 changed files with 6918 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ConnectionConfig {
pub id: String,
pub name: String,
pub host: String,
pub port: u16,
pub user: String,
pub password: String,
pub database: String,
pub ssl_mode: Option<String>,
pub color: Option<String>,
}
impl ConnectionConfig {
pub fn connection_url(&self) -> String {
let ssl = self.ssl_mode.as_deref().unwrap_or("prefer");
format!(
"postgres://{}:{}@{}:{}/{}?sslmode={}",
urlencoded(&self.user),
urlencoded(&self.password),
self.host,
self.port,
urlencoded(&self.database),
ssl
)
}
}
fn urlencoded(s: &str) -> String {
s.chars()
.map(|c| match c {
':' | '/' | '?' | '#' | '[' | ']' | '@' | '!' | '$' | '&' | '\'' | '(' | ')'
| '*' | '+' | ',' | ';' | '=' | '%' | ' ' => {
format!("%{:02X}", c as u8)
}
_ => c.to_string(),
})
.collect()
}