pub struct BackendClient {
pub server_parameters: HashMap<String, String>,
pub backend_pid: Option<u32>,
pub backend_secret: Option<u32>,
/* private fields */
}Expand description
An established, authenticated client connection to a backend.
Fields§
§server_parameters: HashMap<String, String>Parameter values the server sent during startup (client_encoding, server_version, TimeZone, …). Useful for diagnostics.
backend_pid: Option<u32>BackendKeyData cached for potential cancel requests.
backend_secret: Option<u32>Implementations§
Source§impl BackendClient
impl BackendClient
Sourcepub async fn connect(cfg: &BackendConfig) -> BackendResult<Self>
pub async fn connect(cfg: &BackendConfig) -> BackendResult<Self>
Connect, TLS-negotiate, authenticate, and drain server-initialisation
frames through ReadyForQuery. On success the client is idle and
ready to run SQL.
Sourcepub async fn simple_query(&mut self, sql: &str) -> BackendResult<QueryResult>
pub async fn simple_query(&mut self, sql: &str) -> BackendResult<QueryResult>
Run a simple-query (SQL text) and collect every resulting row
into a QueryResult. For statements that don’t return rows
(DDL, SET, etc.) rows will be empty and command_tag
carries the completion string.
Sourcepub async fn query_with_params(
&mut self,
sql: &str,
params: &[ParamValue],
) -> BackendResult<QueryResult>
pub async fn query_with_params( &mut self, sql: &str, params: &[ParamValue], ) -> BackendResult<QueryResult>
Like simple_query but substitutes $1, $2, … with
text-format literals before sending. We stick to simple-query
rather than the extended protocol to keep the surface narrow.
Sourcepub async fn query_scalar(&mut self, sql: &str) -> BackendResult<TextValue>
pub async fn query_scalar(&mut self, sql: &str) -> BackendResult<TextValue>
Shorthand for a scalar lookup: runs sql, expects 1 column, 1 row.
Sourcepub async fn execute(&mut self, sql: &str) -> BackendResult<String>
pub async fn execute(&mut self, sql: &str) -> BackendResult<String>
Run a statement with no result set (DDL, SET, DO). Returns the
command tag (e.g. "SET", "CREATE TABLE").
Auto Trait Implementations§
impl !Freeze for BackendClient
impl !RefUnwindSafe for BackendClient
impl Send for BackendClient
impl Sync for BackendClient
impl Unpin for BackendClient
impl UnsafeUnpin for BackendClient
impl !UnwindSafe for BackendClient
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
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>
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>
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