pub struct ConnectionConfig {
pub database_type: DatabaseType,
pub host: Option<String>,
pub port: Option<u16>,
pub database: String,
pub username: Option<String>,
pub password: Option<String>,
pub connection_pool_size: usize,
pub connection_timeout: u64,
pub additional_params: HashMap<String, String>,
}Expand description
数据库连接配置
Fields§
§database_type: DatabaseType§host: Option<String>§port: Option<u16>§database: String§username: Option<String>§password: Option<String>§connection_pool_size: usize§connection_timeout: u64§additional_params: HashMap<String, String>Implementations§
Source§impl ConnectionConfig
impl ConnectionConfig
Sourcepub fn postgres<H, D, U, P>(
host: H,
database: D,
username: U,
password: P,
) -> Self
pub fn postgres<H, D, U, P>( host: H, database: D, username: U, password: P, ) -> Self
创建PostgreSQL连接配置
Sourcepub fn with_pool_size(self, size: usize) -> Self
pub fn with_pool_size(self, size: usize) -> Self
设置连接池大小
Sourcepub fn with_timeout(self, timeout: u64) -> Self
pub fn with_timeout(self, timeout: u64) -> Self
设置连接超时
Sourcepub fn with_param<K, V>(self, key: K, value: V) -> Self
pub fn with_param<K, V>(self, key: K, value: V) -> Self
添加额外参数
Sourcepub fn to_connection_string(&self) -> Result<String>
pub fn to_connection_string(&self) -> Result<String>
生成连接字符串
Trait Implementations§
Source§impl Clone for ConnectionConfig
impl Clone for ConnectionConfig
Source§fn clone(&self) -> ConnectionConfig
fn clone(&self) -> ConnectionConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ConnectionConfig
impl RefUnwindSafe for ConnectionConfig
impl Send for ConnectionConfig
impl Sync for ConnectionConfig
impl Unpin for ConnectionConfig
impl UnwindSafe for ConnectionConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more