PgConn

Struct PgConn 

Source
pub struct PgConn {
    pub(crate) conn: *mut PGconn,
}

Fields§

§conn: *mut PGconn

Implementations§

Source§

impl PgConn

Source

pub fn connect_db_env_vars() -> Result<PgConn, NulError>

Connect to the database using environment variables.

See the official doc.

Source

pub fn connect_db(s: &str) -> Result<PgConn, NulError>

Source

pub fn status(&self) -> ConnStatusType

Source

pub fn exec(&self, query: &str) -> Result<PgResult, NulError>

Source

pub fn exec_file(&self, file_path: &str) -> Result<PgResult, NulError>

Source

pub fn trace(&mut self, file: &str)

Source

pub fn untrace(&mut self)

Source

pub fn socket(&self) -> PgSocket

Source

pub fn consume_input(&mut self) -> Result<(), String>

Source

pub fn notifies(&mut self) -> Option<PgNotify>

Source

pub fn error_message(&self) -> String

Source

pub(crate) extern "C" fn ffi_notice_processor<F>( arg: *mut c_void, data: *const c_char, )
where F: FnMut(String),

A callback function to receive notices from the server. https://stackoverflow.com/questions/24191249/working-with-c-void-in-an-ffi https://adventures.michaelfbryan.com/posts/rust-closures-in-ffi/

Source

pub fn set_notice_processor<F>(&mut self, proc: F) -> Box<F>
where F: FnMut(String),

Source

pub(crate) extern "C" fn ffi_notice_receiver<F>( arg: *mut c_void, data: *const PGresult, )
where F: FnMut(PgResult),

Source

pub fn set_notice_receiver<F>(&mut self, proc: F) -> Box<F>
where F: FnMut(PgResult),

Sets a notice receiver function to receive notices from the server. Notices are sent to the receiver after command execution is completed. https://www.postgresql.org/docs/current/libpq-notice-processing.html

Source

pub fn listen<F, T>(&mut self, timeout_sec: Option<f64>, proc: F) -> Vec<T>
where F: Fn(usize, PgNotify) -> ControlFlow<(), Option<T>>,

Trait Implementations§

Source§

impl Drop for PgConn

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for PgConn

Source§

impl Sync for PgConn

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, 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.