1
2
3use std::collections::HashMap;
4use json::{JsonValue};
5use crate::config::Config;
6use crate::connect::Connect;
7mod config;
8pub mod connect;
9mod packet;
10mod format;
11
12#[derive(Clone, Debug)]
13pub struct Pgsql {
14 pub config: Config,
16 pub pool: HashMap<String, Connect>,
17}
18
19impl Pgsql {
20 pub fn new(config: JsonValue) -> Result<Self, String> {
22 let config = match Config::new(config) {
23 Ok(e) => e,
24 Err(e) => return Err(format!("配置文件错误: {e}")),
25 };
26 Ok(Self { config, pool: HashMap::new() })
27 }
28 pub fn connect(&mut self) -> Result<Connect, String> {
30 Connect::new(self.config.clone())
31 }
41}