[−][src]Struct libpq::connection::Connection
Implementations
impl Connection
pub fn send_query(&self, command: &str) -> Result<(), String>
Submits a command to the server without waiting for the result(s).
See PQsendQuery.
pub fn send_query_params(
&self,
command: &str,
param_types: &[Oid],
param_values: &[Option<Vec<u8>>],
param_formats: &[Format],
result_format: Format
) -> Result<(), String>
&self,
command: &str,
param_types: &[Oid],
param_values: &[Option<Vec<u8>>],
param_formats: &[Format],
result_format: Format
) -> Result<(), String>
Submits a command and separate parameters to the server without waiting for the result(s).
See PQsendQueryParams.
pub fn send_prepare(
&self,
name: Option<&str>,
query: &str,
param_types: &[Oid]
) -> Result<(), String>
&self,
name: Option<&str>,
query: &str,
param_types: &[Oid]
) -> Result<(), String>
Sends a request to create a prepared statement with the given parameters, without waiting for completion.
See PQsendPrepare.
pub fn send_query_prepared(
&self,
name: Option<&str>,
param_values: &[Option<Vec<u8>>],
param_formats: &[Format],
result_format: Format
) -> Result<(), String>
&self,
name: Option<&str>,
param_values: &[Option<Vec<u8>>],
param_formats: &[Format],
result_format: Format
) -> Result<(), String>
Sends a request to execute a prepared statement with given parameters, without waiting for the result(s).
See PQsendQueryPrepared.
pub fn send_describe_prepared(&self, name: Option<&str>) -> Result<(), String>
Submits a request to obtain information about the specified prepared statement, without waiting for completion.
See PQsendDescribePortal.
pub fn send_describe_portal(&self, name: Option<&str>) -> Result<(), String>
Submits a request to obtain information about the specified portal, without waiting for completion.
See PQsendDescribePortal.
pub fn result(&self) -> Option<Result>
Waits for the next result a prior send_*
call, and returns it.
See PQgetResult.
pub fn consume_input(&self) -> Result<(), String>
If input is available from the server, consume it.
See PQconsumeInput.
pub fn is_busy(&self) -> bool
Returns true
if a command is busy, that is, Result
would block waiting for input.
See PQisBusy.
pub fn set_non_blocking(&self, non_blocking: bool) -> Result<(), ()>
Sets the nonblocking status of the connection.
See PQsetnonblocking.
pub fn is_non_blocking(&self) -> bool
Returns the blocking status of the database connection.
See PQisnonblocking.
pub fn flush(&self) -> Result<(), ()>
Attempts to flush any queued output data to the server.
See PQflush.
impl Connection
pub fn cancel(&self) -> Cancel
Creates a data structure containing the information needed to cancel a command issued through a particular database connection.
See PQgetCancel.
impl Connection
pub fn new(dsn: &str) -> Result<Self, String>
Makes a new connection to the database server.
See PQconnectdb.
pub fn with_params(
params: &HashMap<&str, &str>,
expand_dbname: bool
) -> Result<Self, String>
params: &HashMap<&str, &str>,
expand_dbname: bool
) -> Result<Self, String>
Makes a new connection to the database server.
See PQconnectdbParams.
pub fn start(conninfo: &str) -> Result<Self, String>
Make a connection to the database server in a nonblocking manner.
See PQconnectStart.
pub fn start_params(
params: &HashMap<String, String>,
expand_dbname: bool
) -> Result<Self, String>
params: &HashMap<String, String>,
expand_dbname: bool
) -> Result<Self, String>
Make a connection to the database server in a nonblocking manner.
See PQconnectStartParams.
pub fn set_db(
host: Option<&str>,
port: Option<&str>,
options: Option<&str>,
tty: Option<&str>,
db_name: Option<&str>
) -> Result<Self, String>
host: Option<&str>,
port: Option<&str>,
options: Option<&str>,
tty: Option<&str>,
db_name: Option<&str>
) -> Result<Self, String>
Makes a new connection to the database server.
See PQsetdb.
pub fn login(
host: Option<&str>,
port: Option<&str>,
options: Option<&str>,
tty: Option<&str>,
db_name: Option<&str>,
login: Option<&str>,
pwd: Option<&str>
) -> Result<Self, String>
host: Option<&str>,
port: Option<&str>,
options: Option<&str>,
tty: Option<&str>,
db_name: Option<&str>,
login: Option<&str>,
pwd: Option<&str>
) -> Result<Self, String>
Makes a new connection to the database server.
See PQsetdbLogin.
pub fn poll(&self) -> Status
See PQconnectPoll.
pub fn reset(&self)
Resets the communication channel to the server.
See PQreset.
pub fn reset_start(&self)
Reset the communication channel to the server, in a nonblocking manner.
See PQresetStart.
pub fn reset_poll(&self) -> Status
See PQresetPoll.
pub fn ping_params(
params: &HashMap<String, String>,
expand_dbname: bool
) -> Status
params: &HashMap<String, String>,
expand_dbname: bool
) -> Status
Reports the status of the server.
It accepts connection parameters identical to those of libpq::Connection::with_params
. It
is not necessary to supply correct user name, password, or database name values to obtain
the server status; however, if incorrect values are provided, the server will log a failed
connection attempt.
See PQpingParams.
pub fn ping(dsn: &str) -> Status
Reports the status of the server.
It accepts connection parameters identical to those of libpq::Connection::new
. It is not
necessary to supply correct user name, password, or database name values to obtain the
server status; however, if incorrect values are provided, the server will log a failed
connection attempt.
See PQping.
pub fn info(&self) -> Info
Return the connection options used for the connection
See PQconninfo.
impl Connection
pub fn client_encoding(&self) -> Encoding
Returns the client encoding.
See PQclientEncoding.
pub fn set_client_encoding(&self, encoding: Encoding)
Sets the client encoding.
See PQsetClientEncoding.
pub fn set_error_verbosity(&self, verbosity: Verbosity) -> Verbosity
Determines the verbosity of messages returned by libpq::Connection::error_message
and
libpq::Result::error_message
.
See PQsetErrorVerbosity.
pub fn trace(&self, file: File)
Enables tracing of the client/server communication to a debugging file stream.
See PQtrace.
pub fn untrace(&self)
Disables tracing started by libpq::Connection::trace
.
See PQuntrace.
impl Connection
pub fn put_copy_data(&self, buffer: &str) -> Result<(), String>
Sends data to the server during libpq::Status::CopyIn
state.
See PQputCopyData.
pub fn put_copy_end(&self, errormsg: Option<&str>) -> Result<(), String>
Sends end-of-data indication to the server during libpq::Status::CopyIn
state.
See PQputCopyEnd.
pub fn copy_data(&self, r#async: bool) -> Result<String, String>
Receives data from the server during libpq::Status::CopyOut
state.
See PQgetCopyData.
impl Connection
pub fn exec(&self, query: &str) -> Result
Submits a command to the server and waits for the result.
See PQexec.
pub fn exec_params(
&self,
command: &str,
param_types: &[Oid],
param_values: &[Option<Vec<u8>>],
param_formats: &[Format],
result_format: Format
) -> Result
&self,
command: &str,
param_types: &[Oid],
param_values: &[Option<Vec<u8>>],
param_formats: &[Format],
result_format: Format
) -> Result
Submits a command to the server and waits for the result, with the ability to pass parameters separately from the SQL command text.
See PQexecParams.
pub fn prepare(
&self,
name: Option<&str>,
query: &str,
param_types: &[Oid]
) -> Result
&self,
name: Option<&str>,
query: &str,
param_types: &[Oid]
) -> Result
Submits a request to create a prepared statement with the given parameters, and waits for completion.
See PQprepare.
pub fn exec_prepared(
&self,
name: Option<&str>,
param_values: &[Option<Vec<u8>>],
param_formats: &[Format],
result_format: Format
) -> Result
&self,
name: Option<&str>,
param_values: &[Option<Vec<u8>>],
param_formats: &[Format],
result_format: Format
) -> Result
Sends a request to execute a prepared statement with given parameters, and waits for the result.
See PQexecPrepared.
pub fn describe_prepared(&self, name: Option<&str>) -> Result
Submits a request to obtain information about the specified prepared statement, and waits for completion.
See PQdescribePrepared.
pub fn describe_portal(&self, name: Option<&str>) -> Result
Submits a request to obtain information about the specified portal, and waits for completion.
See PQdescribePortal.
pub fn escape_literal(&self, str: &str) -> Result<String, String>
Escape a string for use within an SQL command.
See PQescapeLiteral.
pub fn escape_identifier(&self, str: &str) -> Result<String, String>
Escapes a string for use as an SQL identifier, such as a table, column, or function name.
See PQescapeIdentifier.
pub fn escape_string(&self, from: &str) -> Result<String, String>
Escape string literals, much like libpq::Connection::literal
.
See PQescapeStringConn.
pub fn escape_bytea(&self, from: &[u8]) -> Result<Vec<u8>, String>
Escapes binary data for use within an SQL command with the type bytea.
See PQescapeByteaConn.
impl Connection
pub unsafe fn set_notice_processor(
&self,
proc: NoticeProcessor,
arg: *mut c_void
) -> NoticeProcessor
&self,
proc: NoticeProcessor,
arg: *mut c_void
) -> NoticeProcessor
Safety
This function takes a void*
pointer as argument.
pub unsafe fn set_notice_receiver(
&self,
proc: NoticeReceiver,
arg: *mut c_void
) -> NoticeReceiver
&self,
proc: NoticeReceiver,
arg: *mut c_void
) -> NoticeReceiver
Safety
This function takes a void*
pointer as argument.
impl Connection
pub fn notifies(&self) -> Option<Notify>
Returns the next notification from a list of unhandled notification messages received from the server.
impl Connection
pub fn set_single_row_mode(&self) -> Result<(), ()>
Select single-row mode for the currently-executing query.
See PQsetSingleRowMode.
impl Connection
pub fn init_openssl(do_ssl: bool, do_crypto: bool)
Allows applications to select which security libraries to initialize.
See PQinitOpenSSL.
pub fn init_ssl(do_ssl: bool)
Allows applications to select which security libraries to initialize.
See PQinitSSL.
impl Connection
pub fn db(&self) -> String
Returns the database name of the connection.
See PQdb.
pub fn user(&self) -> String
Returns the user name of the connection.
See PQuser.
pub fn pass(&self) -> Option<String>
Returns the password of the connection.
See PQpass.
pub fn host(&self) -> String
Returns the server host name of the active connection.
This can be a host name, an IP address, or a directory path if the connection is via Unix socket. (The path case can be distinguished because it will always be an absolute path, beginning with /.)
See PQhost.
pub fn port(&self) -> String
Returns the port of the active connection.
See PQport.
pub fn tty(&self) -> Option<String>
the server no longer pays attention to the TTY setting, but the function remains for backward compatibility.
Returns the debug TTY of the connection.
See PQtty.
pub fn options(&self) -> Option<String>
Returns the command-line options passed in the connection request.
See PQoptions.
pub fn status(&self) -> Status
Returns the status of the connection.
See PQstatus.
pub fn transaction_status(&self) -> Status
Returns the current in-transaction status of the server.
See PQtransactionStatus.
pub fn parameter_status(&self, param: &str) -> String
Looks up a current parameter setting of the server.
See PQparameterStatus.
pub fn protocol_version(&self) -> i32
Interrogates the frontend/backend protocol being used.
See PQprotocolVersion.
pub fn server_version(&self) -> i32
Returns an integer representing the server version.
See PQserverVersion.
pub fn error_message(&self) -> Option<String>
Returns the error message most recently generated by an operation on the connection.
See PQerrorMessage.
pub fn socket(&self) -> Result<i32, ()>
Obtains the file descriptor number of the connection socket to the server.
See PQsocket.
pub fn backend_pid(&self) -> u32
Returns the process ID (PID) of the backend process handling this connection.
See PQbackendPID.
pub fn needs_password(&self) -> bool
Returns true
if the connection authentication method required a password, but none was
available. Returns false
if not.
pub fn used_password(&self) -> bool
Returns true
if the connection authentication method used a password. Returns false
if
not.
pub fn ssl_in_use(&self) -> bool
Returns true
if the connection uses SSL, false
if not.
See PQsslInUse.
pub fn ssl_attribute(&self, attribute: Attribute) -> Option<String>
Returns SSL-related information about the connection.
See PQsslAttribute.
pub fn ssl_attribute_names(&self) -> Vec<Attribute>
Return an array of SSL attribute names available.
See PQsslAttributeNames.
pub unsafe fn ssl_struct(&self, struct_name: &str) -> *const c_void
Return a pointer to an SSL-implementation-specific object describing the connection.
See PQsslStruct.
Safety
This function returns a void*
pointer.
pub unsafe fn ssl(&self) -> *const c_void
impl Connection
pub fn is_thread_safe() -> bool
Returns the thread safety status of the libpq library.
See PQisthreadsafe.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Connection
impl !Sync for Connection
impl Unpin for Connection
impl UnwindSafe for Connection
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,