Struct hdbconnect::ConnectParamsBuilder
source · pub struct ConnectParamsBuilder { /* private fields */ }
Expand description
A builder for ConnectParams
.
§Instantiating a ConnectParamsBuilder
programmatically
use hdbconnect::ConnectParams;
let connect_params = ConnectParams::builder()
.hostname("abcd123")
.port(2222)
.dbuser("MEIER")
.password("schlau")
.build()
.unwrap();
§Instantiating a ConnectParamsBuilder
from a URL
See module url
for details about the supported URLs.
use hdbconnect::IntoConnectParamsBuilder;
let conn_params = "hdbsql://abcd123:2222"
.into_connect_params_builder()
.unwrap()
.dbuser("MEIER")
.password("schlau")
.build()
.unwrap();
Implementations§
source§impl ConnectParamsBuilder
impl ConnectParamsBuilder
sourcepub fn new() -> ConnectParamsBuilder
pub fn new() -> ConnectParamsBuilder
Creates a new builder.
sourcepub fn from(url: &str) -> Result<ConnectParamsBuilder, HdbError>
pub fn from(url: &str) -> Result<ConnectParamsBuilder, HdbError>
Creates a new builder based on the given URL.
sourcepub fn hostname<H>(&mut self, hostname: H) -> &mut ConnectParamsBuilder
pub fn hostname<H>(&mut self, hostname: H) -> &mut ConnectParamsBuilder
Sets the hostname.
sourcepub fn port(&mut self, port: u16) -> &mut ConnectParamsBuilder
pub fn port(&mut self, port: u16) -> &mut ConnectParamsBuilder
Sets the port.
sourcepub fn dbuser<D>(&mut self, dbuser: D) -> &mut ConnectParamsBuilder
pub fn dbuser<D>(&mut self, dbuser: D) -> &mut ConnectParamsBuilder
Sets the database user.
sourcepub fn with_dbuser<D>(self, dbuser: D) -> ConnectParamsBuilder
pub fn with_dbuser<D>(self, dbuser: D) -> ConnectParamsBuilder
Sets the database user.
sourcepub fn password<P>(&mut self, pw: P) -> &mut ConnectParamsBuilder
pub fn password<P>(&mut self, pw: P) -> &mut ConnectParamsBuilder
Sets the password.
sourcepub fn with_password<P>(self, pw: P) -> ConnectParamsBuilder
pub fn with_password<P>(self, pw: P) -> ConnectParamsBuilder
Sets the password.
sourcepub fn unset_password(&mut self) -> &mut ConnectParamsBuilder
pub fn unset_password(&mut self) -> &mut ConnectParamsBuilder
Unsets the password.
sourcepub fn dbname<D>(&mut self, dbname: D) -> &mut ConnectParamsBuilder
pub fn dbname<D>(&mut self, dbname: D) -> &mut ConnectParamsBuilder
Sets the database name.
This allows specifying host and port of the system DB and getting automatically redirected and connected to the specified tenant database.
sourcepub fn network_group<D>(
&mut self,
network_group: D
) -> &mut ConnectParamsBuilder
pub fn network_group<D>( &mut self, network_group: D ) -> &mut ConnectParamsBuilder
Sets the network group.
sourcepub fn clientlocale<P>(&mut self, cl: P) -> &mut ConnectParamsBuilder
pub fn clientlocale<P>(&mut self, cl: P) -> &mut ConnectParamsBuilder
Sets the client locale.
sourcepub fn clientlocale_from_env_lang(&mut self) -> &mut ConnectParamsBuilder
pub fn clientlocale_from_env_lang(&mut self) -> &mut ConnectParamsBuilder
Sets the client locale from the value of the environment variable LANG
sourcepub fn always_uncompressed(
&mut self,
uncompressed: bool
) -> &mut ConnectParamsBuilder
pub fn always_uncompressed( &mut self, uncompressed: bool ) -> &mut ConnectParamsBuilder
Switch off compression (for debugging purposes?)
By default, compression is supported, like with always_uncompressed(false)
sourcepub fn tls_with(
&mut self,
server_certs: ServerCerts
) -> &mut ConnectParamsBuilder
pub fn tls_with( &mut self, server_certs: ServerCerts ) -> &mut ConnectParamsBuilder
Makes the driver use TLS for the connection to the database.
Requires that the server’s certificate is provided with one of the
enum variants of ServerCerts
.
If needed, you can call this function multiple times with different ServerCert
variants.
Example:
let mut conn_params = ConnectParams::builder()
// ...more settings required...
.tls_with(ServerCerts::Direct(string_with_certificate))
.build();
sourcepub fn tls_without_server_verification(&mut self) -> &mut ConnectParamsBuilder
pub fn tls_without_server_verification(&mut self) -> &mut ConnectParamsBuilder
Makes the driver use TLS for the connection to the database, but hazardously without verifying the server’s certificate. Erases all already configured server certs.
sourcepub fn build(&self) -> Result<ConnectParams, HdbError>
pub fn build(&self) -> Result<ConnectParams, HdbError>
Constructs a ConnectParams
from the builder.
§Errors
HdbError::Usage
if the builder was not yet configured to
create a meaningful ConnectParams
sourcepub fn to_url(&self) -> Result<String, HdbError>
pub fn to_url(&self) -> Result<String, HdbError>
Returns the url for this connection, without the password.
§Errors
HdbError::Usage
if the builder was not yet configured to build a correct url
sourcepub fn get_hostname(&self) -> Option<&str>
pub fn get_hostname(&self) -> Option<&str>
Returns the configured hostname.
sourcepub fn get_dbuser(&self) -> Option<&str>
pub fn get_dbuser(&self) -> Option<&str>
Returns the configured database user.
sourcepub fn get_password(&self) -> Option<&SecUtf8>
pub fn get_password(&self) -> Option<&SecUtf8>
Returns the configured password.
sourcepub fn get_clientlocale(&self) -> Option<&str>
pub fn get_clientlocale(&self) -> Option<&str>
Returns the configured client locale.
sourcepub fn get_server_certs(&self) -> Option<&Vec<ServerCerts>>
pub fn get_server_certs(&self) -> Option<&Vec<ServerCerts>>
Returns the configured server certificates.
Trait Implementations§
source§impl Clone for ConnectParamsBuilder
impl Clone for ConnectParamsBuilder
source§fn clone(&self) -> ConnectParamsBuilder
fn clone(&self) -> ConnectParamsBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ConnectParamsBuilder
impl Debug for ConnectParamsBuilder
source§impl Default for ConnectParamsBuilder
impl Default for ConnectParamsBuilder
source§fn default() -> ConnectParamsBuilder
fn default() -> ConnectParamsBuilder
source§impl<'de> Deserialize<'de> for ConnectParamsBuilder
impl<'de> Deserialize<'de> for ConnectParamsBuilder
source§fn deserialize<D>(
deserializer: D
) -> Result<ConnectParamsBuilder, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<ConnectParamsBuilder, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
source§impl Display for ConnectParamsBuilder
impl Display for ConnectParamsBuilder
source§impl IntoConnectParams for &ConnectParamsBuilder
impl IntoConnectParams for &ConnectParamsBuilder
source§fn into_connect_params(self) -> Result<ConnectParams, HdbError>
fn into_connect_params(self) -> Result<ConnectParams, HdbError>
source§impl IntoConnectParams for ConnectParamsBuilder
impl IntoConnectParams for ConnectParamsBuilder
source§fn into_connect_params(self) -> Result<ConnectParams, HdbError>
fn into_connect_params(self) -> Result<ConnectParams, HdbError>
source§impl IntoConnectParamsBuilder for ConnectParamsBuilder
impl IntoConnectParamsBuilder for ConnectParamsBuilder
source§fn into_connect_params_builder(self) -> Result<ConnectParamsBuilder, HdbError>
fn into_connect_params_builder(self) -> Result<ConnectParamsBuilder, HdbError>
source§impl PartialEq for ConnectParamsBuilder
impl PartialEq for ConnectParamsBuilder
source§fn eq(&self, other: &ConnectParamsBuilder) -> bool
fn eq(&self, other: &ConnectParamsBuilder) -> bool
self
and other
values to be equal, and is used
by ==
.