hdbconnect_impl/conn/url.rs
1//! Constants for use in connection URLs.
2//!
3//! Database connections are initialized with an instance of [`ConnectParams`](crate::ConnectParams).
4//! Instances of [`ConnectParams`](crate::ConnectParams)
5//! can be created using a [`ConnectParamsBuilder`](crate::ConnectParamsBuilder), or from a URL.
6//! (Also [`ConnectParamsBuilder`](crate::ConnectParamsBuilder)s can be created from a URL.)
7//!
8//! Such a URL is supposed to have the form
9//!
10//! ```text
11//! <scheme>://<username>:<password>@<host>:<port>[<options>]
12//! ```
13//! where
14//! > `<scheme>` = `hdbsql` | `hdbsqls` // for TCP or TLS connections, respectively\
15//! > `<username>` = the name of the DB user to log on\
16//! > `<password>` = the password of the DB user\
17//! > `<host>` = the host where HANA can be found\
18//! > `<port>` = the port at which HANA can be found on `<host>`\
19//! > `<options>` = `?<key>[=<value>][{&<key>[=<value>]}]`
20//!
21//! __Supported options are:__
22//! - `db=<databasename>` specifies the (MDC) database to which you want to connect
23//! - `client_locale=<value>` is used in language-dependent handling within the
24//! SAP HANA database calculation engine
25//! - `client_locale_from_env` (no value) lets the driver read the client's locale from the
26//! environment variabe LANG
27//! - `<networkgroup>` = a network group
28//! - `no_compression` disables the support for compression
29//! - the [TLS](https://en.wikipedia.org/wiki/Transport_Layer_Security) options:
30// FIXME not only pem files!!
31//! - `tls_certificate_dir=<value>` points to a folder with pem files that contain
32//! certificates; all pem files in that folder are evaluated
33//! - `tls_certificate_env=<value>` denotes an environment variable that contains
34//! certificates
35//! - `use_mozillas_root_certificates` (no value) lets the driver use the root certificates from
36//! [`https://mkcert.org/`](https://mkcert.org/)
37//! - `insecure_omit_server_certificate_check` (no value) lets the driver omit the validation of
38//! the server's identity. Don't use this option in productive setups!
39//!
40//! __To configure TLS__, use the scheme `hdbsqls` and at least one of the TLS options.
41//!
42//! __For a plain connection without TLS__, use the scheme `hdbsql` and none of the TLS options.
43//!
44//! ### Examples
45//!
46//! `ConnectParams` is immutable, the URL must contain all necessary information:
47//! ```rust
48//! use hdbconnect::IntoConnectParams;
49//!
50//! let conn_params = "hdbsql://my_user:my_passwd@the_host:2222"
51//! .into_connect_params()
52//! .unwrap();
53//! ```
54//!
55//! `ConnectParamsBuilder` allows modifications before being converted into a `ConnectParams`:
56//!
57//! ```rust
58//! use hdbconnect::ConnectParamsBuilder;
59//! let conn_params = ConnectParamsBuilder::from("hdbsql://my_user@the_host:2222")
60//! .unwrap()
61//! .with_password("no-secrets-in-urls")
62//! .build()
63//! .unwrap();
64//! ```
65
66/// Protocol without TLS
67pub const HDBSQL: &str = "hdbsql";
68
69/// Protocol with TLS
70pub const HDBSQLS: &str = "hdbsqls";
71
72/// Option-key for denoting a folder in which server certificates can be found.
73pub const TLS_CERTIFICATE_DIR: &str = "tls_certificate_dir";
74
75/// Option-key for denoting an environment variable in which a server certificate can be found
76pub const TLS_CERTIFICATE_ENV: &str = "tls_certificate_env";
77
78/// option-key for defining that the server roots from <https://mkcert.org/> should be added to the
79/// trust store for TLS.
80pub const USE_MOZILLAS_ROOT_CERTIFICATES: &str = "use_mozillas_root_certificates";
81
82/// Option-key for defining that the server's identity is not validated. Don't use this
83/// option in productive setups!
84pub const INSECURE_OMIT_SERVER_CERTIFICATE_CHECK: &str = "insecure_omit_server_certificate_check";
85
86/// Option-key for denoting the client locale.
87pub const CLIENT_LOCALE: &str = "client_locale";
88
89/// Option-key for denoting an environment variable which contains the client locale.
90pub const CLIENT_LOCALE_FROM_ENV: &str = "client_locale_from_env";
91
92/// Option-key for denoting the (MDC) database to which you want to connect; when using this option,
93/// `<host>` and `<port>` must specify the system database
94pub const DATABASE: &str = "db";
95
96/// Option-key for denoting a network group.
97pub const NETWORK_GROUP: &str = "network_group";
98
99/// Option-key for switching off compression
100pub const NO_COMPRESSION: &str = "no_compression";