Struct xitca_postgres::Config
source · pub struct Config { /* private fields */ }
Implementations§
source§impl Config
impl Config
sourcepub fn user(&mut self, user: &str) -> &mut Config
pub fn user(&mut self, user: &str) -> &mut Config
Sets the user to authenticate with.
Required.
sourcepub fn get_user(&self) -> Option<&str>
pub fn get_user(&self) -> Option<&str>
Gets the user to authenticate with, if one has been configured with
the user
method.
sourcepub fn password<T>(&mut self, password: T) -> &mut Config
pub fn password<T>(&mut self, password: T) -> &mut Config
Sets the password to authenticate with.
sourcepub fn get_password(&self) -> Option<&[u8]>
pub fn get_password(&self) -> Option<&[u8]>
Gets the password to authenticate with, if one has been configured with
the password
method.
sourcepub fn dbname(&mut self, dbname: &str) -> &mut Config
pub fn dbname(&mut self, dbname: &str) -> &mut Config
Sets the name of the database to connect to.
Defaults to the user.
sourcepub fn get_dbname(&self) -> Option<&str>
pub fn get_dbname(&self) -> Option<&str>
Gets the name of the database to connect to, if one has been configured
with the dbname
method.
sourcepub fn options(&mut self, options: &str) -> &mut Config
pub fn options(&mut self, options: &str) -> &mut Config
Sets command line options used to configure the server.
sourcepub fn get_options(&self) -> Option<&str>
pub fn get_options(&self) -> Option<&str>
Gets the command line options used to configure the server, if the
options have been set with the options
method.
sourcepub fn application_name(&mut self, application_name: &str) -> &mut Config
pub fn application_name(&mut self, application_name: &str) -> &mut Config
Sets the value of the application_name
runtime parameter.
sourcepub fn get_application_name(&self) -> Option<&str>
pub fn get_application_name(&self) -> Option<&str>
Gets the value of the application_name
runtime parameter, if it has
been set with the application_name
method.
sourcepub fn ssl_mode(&mut self, ssl_mode: SslMode) -> &mut Config
pub fn ssl_mode(&mut self, ssl_mode: SslMode) -> &mut Config
Sets the SSL configuration.
Defaults to prefer
.
sourcepub fn get_ssl_mode(&self) -> SslMode
pub fn get_ssl_mode(&self) -> SslMode
Gets the SSL configuration.
pub fn host(&mut self, host: &str) -> &mut Config
sourcepub fn host_path<T>(&mut self, host: T) -> &mut Config
pub fn host_path<T>(&mut self, host: T) -> &mut Config
Adds a Unix socket host to the configuration.
Unlike host
, this method allows non-UTF8 paths.
sourcepub fn get_hosts(&self) -> &[Host]
pub fn get_hosts(&self) -> &[Host]
Gets the hosts that have been added to the configuration with host
.
sourcepub fn port(&mut self, port: u16) -> &mut Config
pub fn port(&mut self, port: u16) -> &mut Config
Adds a port to the configuration.
Multiple ports can be specified by calling this method multiple times. There must either be no ports, in which case the default of 5432 is used, a single port, in which it is used for all hosts, or the same number of ports as hosts.
sourcepub fn get_ports(&self) -> &[u16]
pub fn get_ports(&self) -> &[u16]
Gets the ports that have been added to the configuration with port
.
sourcepub fn target_session_attrs(
&mut self,
target_session_attrs: TargetSessionAttrs,
) -> &mut Config
pub fn target_session_attrs( &mut self, target_session_attrs: TargetSessionAttrs, ) -> &mut Config
Sets the requirements of the session.
This can be used to connect to the primary server in a clustered database rather than one of the read-only
secondary servers. Defaults to Any
.
sourcepub fn get_target_session_attrs(&self) -> TargetSessionAttrs
pub fn get_target_session_attrs(&self) -> TargetSessionAttrs
Gets the requirements of the session.
sourcepub fn tls_server_end_point(
&mut self,
tls_server_end_point: impl AsRef<[u8]>,
) -> &mut Self
pub fn tls_server_end_point( &mut self, tls_server_end_point: impl AsRef<[u8]>, ) -> &mut Self
change the remote peer’s tls certificates. it’s often coupled with Postgres::connect_io
API for manual tls
session connecting and channel binding authentication.
§Examples
use xitca_postgres::{Config, Postgres};
// handle tls connection on your own.
async fn connect_io() {
let mut cfg = Config::try_from("postgres://postgres:postgres@localhost/postgres").unwrap();
// an imaginary function where you establish a tls connection to database on your own.
// the established connection should be providing valid cert bytes.
let (io, certs) = your_tls_connector().await;
// set cert bytes to configuration
cfg.tls_server_end_point(certs);
// give xitca-postgres the config and established io and finish db session process.
let _ = Postgres::new(cfg).connect_io(io).await;
}
async fn your_tls_connector() -> (MyTlsStream, Vec<u8>) {
todo!("your tls connecting logic lives here. the process can be async or not.")
}
// a possible type representation of your manual tls connection to database
struct MyTlsStream;
pub fn get_tls_server_end_point(&self) -> Option<&[u8]>
Trait Implementations§
impl Eq for Config
impl StructuralPartialEq for Config
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)