Skip to main content

Connect

Struct Connect 

Source
pub struct Connect { /* private fields */ }

Implementations§

Source§

impl Connect

Source

pub fn is_valid(&mut self) -> bool

懒健康检查:peer_addr 检测 TCP 存活,空闲超过 30 秒才发 SELECT 1

Source

pub fn peer_valid(&self) -> bool

仅检查 TCP 连接是否存活(不发送查询)

Source

pub fn touch(&mut self)

更新最后使用时间

Source

pub fn idle_elapsed(&self) -> Duration

返回空闲时长

Source

pub fn _close(&mut self)

Source

pub fn new(config: Config) -> Result<Connect, PgsqlError>

Source

pub fn query(&mut self, sql: &str) -> Result<SuccessMessage, PgsqlError>

Source

pub fn execute(&mut self, sql: &str) -> Result<SuccessMessage, PgsqlError>

Source

pub fn query_params( &mut self, sql: &str, params: &[Option<&str>], ) -> Result<SuccessMessage, PgsqlError>

参数化查询

Source

pub fn execute_params( &mut self, sql: &str, params: &[Option<&str>], ) -> Result<SuccessMessage, PgsqlError>

参数化执行

Source

pub fn query_str( &mut self, sql: &str, params: &[&str], ) -> Result<SuccessMessage, PgsqlError>

参数化查询(便捷版,所有参数非 NULL)

Source

pub fn execute_str( &mut self, sql: &str, params: &[&str], ) -> Result<SuccessMessage, PgsqlError>

参数化执行(便捷版,所有参数非 NULL)

Trait Implementations§

Source§

impl Debug for Connect

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Connect

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.