[−][src]Struct deadpool_postgres::Client
Methods
impl Client
[src]
pub fn new(client: PgClient) -> Client
[src]
pub async fn prepare<'_, '_>(
&'_ mut self,
sql: &'_ str
) -> Result<Statement, Error>
[src]
&'_ mut self,
sql: &'_ str
) -> Result<Statement, Error>
Methods from Deref<Target = PgClient>
pub async fn prepare(&'_ self, query: &'_ str) -> Result<Statement, Error>
[src]
Creates a new prepared statement.
Prepared statements can be executed repeatedly, and may contain query parameters (indicated by $1
, $2
, etc),
which are set when executed. Prepared statements can only be used with the connection that created them.
pub async fn prepare_typed(
&'_ self,
query: &'_ str,
parameter_types: &'_ [Type]
) -> Result<Statement, Error>
[src]
&'_ self,
query: &'_ str,
parameter_types: &'_ [Type]
) -> Result<Statement, Error>
Like prepare
, but allows the types of query parameters to be explicitly specified.
The list of types may be smaller than the number of parameters - the types of the remaining parameters will be
inferred. For example, client.prepare_typed(query, &[])
is equivalent to client.prepare(query)
.
pub async fn query<T>(
&'_ self,
statement: &'_ T,
params: &'_ [&'_ (dyn ToSql + '_ + Sync)]
) -> Result<Vec<Row>, Error> where
T: ToStatement + ?Sized,
[src]
&'_ self,
statement: &'_ T,
params: &'_ [&'_ (dyn ToSql + '_ + Sync)]
) -> Result<Vec<Row>, Error> where
T: ToStatement + ?Sized,
Executes a statement, returning a vector of the resulting rows.
A statement may contain parameters, specified by $n
, where n
is the index of the parameter of the list
provided, 1-indexed.
The statement
argument can either be a Statement
, or a raw query string. If the same statement will be
repeatedly executed (perhaps with different query parameters), consider preparing the statement up front
with the prepare
method.
Panics
Panics if the number of parameters provided does not match the number expected.
pub async fn query_one<T>(
&'_ self,
statement: &'_ T,
params: &'_ [&'_ (dyn ToSql + '_ + Sync)]
) -> Result<Row, Error> where
T: ToStatement + ?Sized,
[src]
&'_ self,
statement: &'_ T,
params: &'_ [&'_ (dyn ToSql + '_ + Sync)]
) -> Result<Row, Error> where
T: ToStatement + ?Sized,
Executes a statement which returns a single row, returning it.
A statement may contain parameters, specified by $n
, where n
is the index of the parameter of the list
provided, 1-indexed.
The statement
argument can either be a Statement
, or a raw query string. If the same statement will be
repeatedly executed (perhaps with different query parameters), consider preparing the statement up front
with the prepare
method.
Returns an error if the query does not return exactly one row.
Panics
Panics if the number of parameters provided does not match the number expected.
pub async fn query_raw<'a, T, I>(
&'_ self,
statement: &'_ T,
params: I
) -> Result<RowStream, Error> where
I: IntoIterator<Item = &'a (dyn ToSql + 'a)>,
T: ToStatement + ?Sized,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
[src]
&'_ self,
statement: &'_ T,
params: I
) -> Result<RowStream, Error> where
I: IntoIterator<Item = &'a (dyn ToSql + 'a)>,
T: ToStatement + ?Sized,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
The maximally flexible version of query
.
A statement may contain parameters, specified by $n
, where n
is the index of the parameter of the list
provided, 1-indexed.
The statement
argument can either be a Statement
, or a raw query string. If the same statement will be
repeatedly executed (perhaps with different query parameters), consider preparing the statement up front
with the prepare
method.
Panics
Panics if the number of parameters provided does not match the number expected.
pub async fn execute<T>(
&'_ self,
statement: &'_ T,
params: &'_ [&'_ (dyn ToSql + '_ + Sync)]
) -> Result<u64, Error> where
T: ToStatement + ?Sized,
[src]
&'_ self,
statement: &'_ T,
params: &'_ [&'_ (dyn ToSql + '_ + Sync)]
) -> Result<u64, Error> where
T: ToStatement + ?Sized,
Executes a statement, returning the number of rows modified.
A statement may contain parameters, specified by $n
, where n
is the index of the parameter of the list
provided, 1-indexed.
The statement
argument can either be a Statement
, or a raw query string. If the same statement will be
repeatedly executed (perhaps with different query parameters), consider preparing the statement up front
with the prepare
method.
If the statement does not modify any rows (e.g. SELECT
), 0 is returned.
Panics
Panics if the number of parameters provided does not match the number expected.
pub async fn execute_raw<'a, T, I>(
&'_ self,
statement: &'_ T,
params: I
) -> Result<u64, Error> where
I: IntoIterator<Item = &'a (dyn ToSql + 'a)>,
T: ToStatement + ?Sized,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
[src]
&'_ self,
statement: &'_ T,
params: I
) -> Result<u64, Error> where
I: IntoIterator<Item = &'a (dyn ToSql + 'a)>,
T: ToStatement + ?Sized,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
The maximally flexible version of execute
.
A statement may contain parameters, specified by $n
, where n
is the index of the parameter of the list
provided, 1-indexed.
The statement
argument can either be a Statement
, or a raw query string. If the same statement will be
repeatedly executed (perhaps with different query parameters), consider preparing the statement up front
with the prepare
method.
Panics
Panics if the number of parameters provided does not match the number expected.
pub async fn copy_in<T, S>(
&'_ self,
statement: &'_ T,
params: &'_ [&'_ (dyn ToSql + '_ + Sync)],
stream: S
) -> Result<u64, Error> where
S: TryStream,
T: ToStatement + ?Sized,
<S as TryStream>::Ok: IntoBuf,
<<S as TryStream>::Ok as IntoBuf>::Buf: 'static,
<<S as TryStream>::Ok as IntoBuf>::Buf: Send,
<S as TryStream>::Error: Into<Box<dyn Error + 'static + Send + Sync>>,
[src]
&'_ self,
statement: &'_ T,
params: &'_ [&'_ (dyn ToSql + '_ + Sync)],
stream: S
) -> Result<u64, Error> where
S: TryStream,
T: ToStatement + ?Sized,
<S as TryStream>::Ok: IntoBuf,
<<S as TryStream>::Ok as IntoBuf>::Buf: 'static,
<<S as TryStream>::Ok as IntoBuf>::Buf: Send,
<S as TryStream>::Error: Into<Box<dyn Error + 'static + Send + Sync>>,
Executes a COPY FROM STDIN
statement, returning the number of rows created.
The data in the provided stream is passed along to the server verbatim; it is the caller's responsibility to ensure it uses the proper format.
Panics
Panics if the number of parameters provided does not match the number expected.
pub async fn copy_out<T>(
&'_ self,
statement: &'_ T,
params: &'_ [&'_ (dyn ToSql + '_ + Sync)]
) -> Result<CopyStream, Error> where
T: ToStatement + ?Sized,
[src]
&'_ self,
statement: &'_ T,
params: &'_ [&'_ (dyn ToSql + '_ + Sync)]
) -> Result<CopyStream, Error> where
T: ToStatement + ?Sized,
Executes a COPY TO STDOUT
statement, returning a stream of the resulting data.
Panics
Panics if the number of parameters provided does not match the number expected.
pub async fn simple_query(
&'_ self,
query: &'_ str
) -> Result<Vec<SimpleQueryMessage>, Error>
[src]
&'_ self,
query: &'_ str
) -> Result<Vec<SimpleQueryMessage>, Error>
Executes a sequence of SQL statements using the simple query protocol, returning the resulting rows.
Statements should be separated by semicolons. If an error occurs, execution of the sequence will stop at that
point. The simple query protocol returns the values in rows as strings rather than in their binary encodings,
so the associated row type doesn't work with the FromSql
trait. Rather than simply returning a stream over the
rows, this method returns a stream over an enum which indicates either the completion of one of the commands,
or a row of data. This preserves the framing between the separate statements in the request.
Warning
Prepared statements should be use for any query which contains user-specified data, as they provided the functionality to safely embed that data in the request. Do not form statements via string concatenation and pass them to this method!
pub async fn batch_execute(&'_ self, query: &'_ str) -> Result<(), Error>
[src]
Executes a sequence of SQL statements using the simple query protocol.
Statements should be separated by semicolons. If an error occurs, execution of the sequence will stop at that point. This is intended for use when, for example, initializing a database schema.
Warning
Prepared statements should be use for any query which contains user-specified data, as they provided the functionality to safely embed that data in the request. Do not form statements via string concatenation and pass them to this method!
pub async fn transaction(&'_ mut self) -> Result<Transaction<'_>, Error>
[src]
Begins a new database transaction.
The transaction will roll back by default - use the commit
method to commit it.
pub async fn cancel_query<T>(&'_ self, tls: T) -> Result<(), Error> where
T: MakeTlsConnect<Socket>,
[src]
T: MakeTlsConnect<Socket>,
Attempts to cancel an in-progress query.
The server provides no information about whether a cancellation attempt was successful or not. An error will only be returned if the client was unable to connect to the database.
Requires the runtime
Cargo feature (enabled by default).
pub async fn cancel_query_raw<S, T>(
&'_ self,
stream: S,
tls: T
) -> Result<(), Error> where
S: AsyncRead + AsyncWrite + Unpin,
T: TlsConnect<S>,
[src]
&'_ self,
stream: S,
tls: T
) -> Result<(), Error> where
S: AsyncRead + AsyncWrite + Unpin,
T: TlsConnect<S>,
Like cancel_query
, but uses a stream which is already connected to the server rather than opening a new
connection itself.
pub fn is_closed(&self) -> bool
[src]
Determines if the connection to the server has already closed.
In that case, all future queries will fail.
Trait Implementations
impl Deref for Client
[src]
impl DerefMut for Client
[src]
impl<T> Manager<Client, Error> for Manager<T> where
T: MakeTlsConnect<Socket> + Clone + Sync + Send + 'static,
T::Stream: Sync + Send,
T::TlsConnect: Sync + Send,
<T::TlsConnect as TlsConnect<Socket>>::Future: Send,
[src]
T: MakeTlsConnect<Socket> + Clone + Sync + Send + 'static,
T::Stream: Sync + Send,
T::TlsConnect: Sync + Send,
<T::TlsConnect as TlsConnect<Socket>>::Future: Send,
fn create<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Client, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Client, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn recycle<'life0, 'async_trait>(
&'life0 self,
client: Client
) -> Pin<Box<dyn Future<Output = Result<Client, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self,
client: Client
) -> Pin<Box<dyn Future<Output = Result<Client, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Auto Trait Implementations
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
impl !RefUnwindSafe for Client
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
type Output = T
Should always be Self