pub struct Connection { /* private fields */ }Expand description
An asynchronous connection to the database.
Implementations§
Source§impl Connection
impl Connection
Sourcepub async fn new<P>(params: P) -> Result<Connection, HdbError>where
P: IntoConnectParams,
pub async fn new<P>(params: P) -> Result<Connection, HdbError>where
P: IntoConnectParams,
Factory method for authenticated connections.
See ConnectParams,
ConnectParamsBuilder, and IntoConnectParams
for the available options of providing the input to this function.
§Example
use hdbconnect_async::Connection;
let mut conn = Connection::new("hdbsql://my_user:my_passwd@the_host:2222").await.unwrap();§Errors
Several variants of HdbError can occur.
Sourcepub async fn with_configuration<P>(
params: P,
config: &ConnectionConfiguration,
) -> Result<Connection, HdbError>where
P: IntoConnectParams,
pub async fn with_configuration<P>(
params: P,
config: &ConnectionConfiguration,
) -> Result<Connection, HdbError>where
P: IntoConnectParams,
Factory method for authenticated connections with given configuration.
§Errors
Several variants of HdbError can occur.
Sourcepub async fn statement<S>(&self, stmt: S) -> Result<HdbResponse, HdbError>
pub async fn statement<S>(&self, stmt: S) -> Result<HdbResponse, HdbError>
Executes a statement on the database.
This generic method can handle all kinds of calls,
and thus has the most generic return type.
In many cases it will be more convenient to use
one of the dedicated methods query(), dml(), exec() below, which
internally convert the HdbResponse to the
respective adequate simple result type.
§Example
let mut response = connection.statement(&statement_string).await.unwrap(); // HdbResponse§Errors
Several variants of HdbError can occur.
Sourcepub async fn prepare<S>(&self, stmt: S) -> Result<PreparedStatement, HdbError>
pub async fn prepare<S>(&self, stmt: S) -> Result<PreparedStatement, HdbError>
Prepares a statement and returns a handle (a PreparedStatement) to it.
Note that the PreparedStatement keeps using the same database connection as
this Connection.
§Example
let query_string = "select * from phrases where ID = ? and text = ?";
let mut statement = connection.prepare(query_string).await.unwrap(); //PreparedStatement§Errors
Several variants of HdbError can occur.
Sourcepub async fn prepare_and_execute<S, T>(
&self,
stmt: S,
input: &T,
) -> Result<HdbResponse, HdbError>
pub async fn prepare_and_execute<S, T>( &self, stmt: S, input: &T, ) -> Result<HdbResponse, HdbError>
Sourcepub async fn spawn(&self) -> Result<Connection, HdbError>
pub async fn spawn(&self) -> Result<Connection, HdbError>
Creates a new connection object with the same settings and authentication.
§Errors
Several variants of HdbError can occur.
Sourcepub async fn multiple_statements_ignore_err<S>(&self, stmts: Vec<S>)
pub async fn multiple_statements_ignore_err<S>(&self, stmts: Vec<S>)
Utility method to fire a couple of statements, ignoring errors and return values.
§Errors
Several variants of HdbError can occur.
Sourcepub async fn multiple_statements<S>(
&self,
stmts: Vec<S>,
) -> Result<(), HdbError>
pub async fn multiple_statements<S>( &self, stmts: Vec<S>, ) -> Result<(), HdbError>
Utility method to fire a couple of statements, ignoring their return
values; the method returns with the first error, or with ().
§Errors
Several variants of HdbError can occur.
Sourcepub async fn pop_warnings(&self) -> Option<Vec<ServerError>>
pub async fn pop_warnings(&self) -> Option<Vec<ServerError>>
Returns warnings that were returned from the server since the last call to this method.
Sourcepub async fn set_auto_commit(&self, ac: bool)
pub async fn set_auto_commit(&self, ac: bool)
Sets the connection’s auto-commit behavior.
Sourcepub async fn is_auto_commit(&self) -> bool
pub async fn is_auto_commit(&self) -> bool
Returns the connection’s auto-commit behavior.
Sourcepub async fn set_cursor_holdability(
&self,
holdability: CursorHoldability,
) -> Result<(), HdbError>
pub async fn set_cursor_holdability( &self, holdability: CursorHoldability, ) -> Result<(), HdbError>
Sourcepub async fn cursor_holdability(&self) -> Result<CursorHoldability, HdbError>
pub async fn cursor_holdability(&self) -> Result<CursorHoldability, HdbError>
Sourcepub async fn fetch_size(&self) -> u32
pub async fn fetch_size(&self) -> u32
Returns the connection’s fetch size.
Sourcepub async fn set_fetch_size(&self, fetch_size: u32)
pub async fn set_fetch_size(&self, fetch_size: u32)
Configures the connection’s fetch size.
Sourcepub async fn set_read_timeout(
&self,
read_timeout: Option<Duration>,
) -> Result<(), HdbError>
pub async fn set_read_timeout( &self, read_timeout: Option<Duration>, ) -> Result<(), HdbError>
Sourcepub async fn lob_read_length(&self) -> u32
pub async fn lob_read_length(&self) -> u32
Returns the connection’s lob read length.
Sourcepub async fn set_lob_read_length(&self, l: u32)
pub async fn set_lob_read_length(&self, l: u32)
Sourcepub async fn lob_write_length(&self) -> u32
pub async fn lob_write_length(&self) -> u32
Returns the connection’s lob write length.
Sourcepub async fn set_lob_write_length(&self, l: u32)
pub async fn set_lob_write_length(&self, l: u32)
Sets the connection’s lob write length.
The intention of the parameter is to allow reducing the number of roundtrips to the database.
Sourcepub async fn set_max_buffer_size(&mut self, max_buffer_size: usize)
pub async fn set_max_buffer_size(&mut self, max_buffer_size: usize)
Sets the connection’s maximum buffer size.
Sourcepub async fn id(&self) -> u32
pub async fn id(&self) -> u32
Returns the ID of the connection.
The ID is set by the server. Can be handy for logging.
Sourcepub async fn server_usage(&self) -> ServerUsage
pub async fn server_usage(&self) -> ServerUsage
Provides information about the the server-side resource consumption that is related to this Connection object.
Sourcepub async fn statistics(&self) -> ConnectionStatistics
pub async fn statistics(&self) -> ConnectionStatistics
Returns some statistics snapshot about what was done with this connection so far.
Sourcepub async fn reset_statistics(&self)
pub async fn reset_statistics(&self)
Reset the counters in the Connection’s statistic object.
Sourcepub async fn set_application<S>(&self, application: S)
pub async fn set_application<S>(&self, application: S)
Sets client information into a session variable on the server.
Example:
connection.set_application("MyApp, built in rust").await;Sourcepub async fn set_application_user<S>(&self, appl_user: S)
pub async fn set_application_user<S>(&self, appl_user: S)
Sets client information into a session variable on the server.
Example:
connection.set_application_user("K2209657").await;Sourcepub async fn set_application_version<S>(&self, version: S)
pub async fn set_application_version<S>(&self, version: S)
Sets client information into a session variable on the server.
Example:
connection.set_application_version("5.3.23").await.unwrap();Sourcepub async fn set_application_source<S>(&self, source: S)
pub async fn set_application_source<S>(&self, source: S)
Sets client information into a session variable on the server.
Example:
connection.set_application_source("update_customer.rs").await.unwrap();Sourcepub fn get_resource_manager(&self) -> Box<dyn ResourceManager>
pub fn get_resource_manager(&self) -> Box<dyn ResourceManager>
Returns an implementation of dist_tx_async::rm::ResourceManager that is
based on this connection.
Sourcepub async fn execute_with_debuginfo<S>(
&mut self,
stmt: S,
module: S,
line: u32,
) -> Result<HdbResponse, HdbError>
pub async fn execute_with_debuginfo<S>( &mut self, stmt: S, module: S, line: u32, ) -> Result<HdbResponse, HdbError>
Tools like debuggers can provide additional information while stepping through a source.
§Errors
Several variants of HdbError can occur.
Sourcepub async fn get_database_name(&self) -> String
pub async fn get_database_name(&self) -> String
(MDC) Database name.
Sourcepub async fn get_system_id(&self) -> String
pub async fn get_system_id(&self) -> String
The system id is set by the server with the SAPSYSTEMNAME of the connected instance (for tracing and supportability purposes).
Sourcepub async fn client_info(&self) -> Vec<(String, String)>
pub async fn client_info(&self) -> Vec<(String, String)>
Returns the information that is given to the server as client context.
Sourcepub async fn connect_string(&self) -> String
pub async fn connect_string(&self) -> String
Returns a connect url (excluding the password) that reflects the options that were used to establish this connection.
Sourcepub async fn get_full_version_string(&self) -> String
pub async fn get_full_version_string(&self) -> String
HANA Full version string.
§Errors
Errors are unlikely to occur.
HdbErr::Implif the version string was not provided by the database server.HdbError::Poisonif the shared mutex of the inner connection object is poisened.
Trait Implementations§
Source§impl Clone for Connection
impl Clone for Connection
Source§fn clone(&self) -> Connection
fn clone(&self) -> Connection
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for Connection
impl !RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl !UnwindSafe for Connection
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoCollection<T> for T
impl<T> IntoCollection<T> for T
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 moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);