ConnectParamsBuilder

Struct 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

Source

pub fn new() -> Self

Creates a new builder.

Source

pub fn from(url: &str) -> HdbResult<Self>

Creates a new builder based on the given URL.

§Errors

HdbError::Usage when parsing or evaluating the url failed.

Source

pub fn hostname<H: AsRef<str>>(&mut self, hostname: H) -> &mut Self

Sets the hostname.

Source

pub fn with_hostname<H: AsRef<str>>(self, hostname: H) -> Self

Sets the hostname.

Source

pub fn port(&mut self, port: u16) -> &mut Self

Sets the port.

Source

pub fn with_port(self, port: u16) -> Self

Sets the port.

Source

pub fn dbuser<D: AsRef<str>>(&mut self, dbuser: D) -> &mut Self

Sets the database user.

Source

pub fn with_dbuser<D: AsRef<str>>(self, dbuser: D) -> Self

Sets the database user.

Source

pub fn password<P: AsRef<str>>(&mut self, pw: P) -> &mut Self

Sets the password.

Source

pub fn with_password<P: AsRef<str>>(self, pw: P) -> Self

Sets the password.

Source

pub fn unset_password(&mut self) -> &mut Self

Unsets the password.

Source

pub fn is_tls(&self) -> bool

Whether TLS or a plain TCP connection is to be used.

Source

pub fn dbname<D: AsRef<str>>(&mut self, dbname: D) -> &mut Self

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.

Source

pub fn with_dbname<D: AsRef<str>>(self, dbname: D) -> Self

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.

Source

pub fn network_group<D: AsRef<str>>(&mut self, network_group: D) -> &mut Self

Sets the network group.

Source

pub fn clientlocale<P: AsRef<str>>(&mut self, cl: P) -> &mut Self

Sets the client locale.

Source

pub fn clientlocale_from_env_lang(&mut self) -> &mut Self

Sets the client locale from the value of the environment variable LANG

Source

pub fn always_uncompressed(&mut self, uncompressed: bool) -> &mut Self

Switch off compression (for debugging purposes?)

By default, compression is supported, like with always_uncompressed(false)

Source

pub fn tls_with(&mut self, server_certs: ServerCerts) -> &mut Self

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.

Source

pub fn with_tls_with(self, server_certs: ServerCerts) -> Self

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...
   .with_tls_with(ServerCerts::Direct(string_with_certificate))
   .build();
Source

pub fn tls_without_server_verification(&mut self) -> &mut Self

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.

Source

pub fn with_tls_without_server_verification(self, with_tls: bool) -> Self

Decides whether the driver use TLS for the connection to the database, or not. If yes, it chooses the hazardous option without verifying the server’s certificate. Erases all already configured server certs.

Source

pub fn build(&self) -> HdbResult<ConnectParams>

Constructs a ConnectParams from the builder.

§Errors

HdbError::Usage if the builder was not yet configured to create a meaningful ConnectParams

Source

pub fn to_url_without_password(&self) -> String

Returns the url for this connection, without the password.

Source

pub fn to_url_with_password(&self) -> String

Returns the url for this connection with the password.

Source

pub fn get_hostname(&self) -> Option<&str>

Returns the configured hostname.

Source

pub fn get_dbuser(&self) -> Option<&str>

Returns the configured database user.

Source

pub fn get_password(&self) -> Option<&SecUtf8>

Returns the configured password.

Source

pub fn get_port(&self) -> Option<u16>

Returns the configured port number.

Source

pub fn get_clientlocale(&self) -> Option<&str>

Returns the configured client locale.

Source

pub fn get_dbname(&self) -> Option<&str>

Returns the configured database name.

Source

pub fn get_networkgroup(&self) -> Option<&str>

Returns the configured network group.

Source

pub fn get_server_certs(&self) -> Option<&Vec<ServerCerts>>

Returns the configured variants for validating the server certificate.

Trait Implementations§

Source§

impl Clone for ConnectParamsBuilder

Source§

fn clone(&self) -> ConnectParamsBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ConnectParamsBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ConnectParamsBuilder

Source§

fn default() -> ConnectParamsBuilder

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ConnectParamsBuilder

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for ConnectParamsBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<ConnectParamsBuilder> for String

Source§

fn from(cpb: ConnectParamsBuilder) -> String

Converts to this type from the input type.
Source§

impl IntoConnectParams for &ConnectParamsBuilder

Source§

fn into_connect_params(self) -> HdbResult<ConnectParams>

Converts the value of self into a ConnectParams. Read more
Source§

impl IntoConnectParams for ConnectParamsBuilder

Source§

fn into_connect_params(self) -> HdbResult<ConnectParams>

Converts the value of self into a ConnectParams. Read more
Source§

impl IntoConnectParamsBuilder for ConnectParamsBuilder

Source§

fn into_connect_params_builder(self) -> HdbResult<ConnectParamsBuilder>

Converts the value of self into a ConnectParamsBuilder. Read more
Source§

impl PartialEq for ConnectParamsBuilder

Source§

fn eq(&self, other: &ConnectParamsBuilder) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ConnectParamsBuilder

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for ConnectParamsBuilder

Source§

impl StructuralPartialEq for ConnectParamsBuilder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,