pub struct Config { /* private fields */ }Expand description
Configuration for a Hyper database connection.
Use the builder pattern to construct a configuration:
// Marked `no_run` to dodge a Windows Defender heuristic that intermittently
// refuses to launch this specific compiled doctest binary with
// `ERROR_ACCESS_DENIED`. The same builder chain is exercised by
// `tests::test_config_builder` so coverage is preserved.
use hyperdb_api_core::client::Config;
use std::time::Duration;
let config = Config::new()
.with_host("localhost")
.with_port(7483)
.with_database("test.hyper")
.with_user("myuser")
.with_password("mypass")
.with_connect_timeout(Duration::from_secs(30));Implementations§
Source§impl Config
impl Config
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new configuration with default settings.
By default, this sets result_format_code=HyperBinary for optimal
performance with Hyper’s native binary format.
Sourcepub fn with_database(self, database: impl Into<String>) -> Self
pub fn with_database(self, database: impl Into<String>) -> Self
Sets the database name.
Sourcepub fn with_password(self, password: impl Into<String>) -> Self
pub fn with_password(self, password: impl Into<String>) -> Self
Sets the password.
Sourcepub fn with_connect_timeout(self, timeout: Duration) -> Self
pub fn with_connect_timeout(self, timeout: Duration) -> Self
Sets the connection timeout.
Sourcepub fn with_application_name(self, name: impl Into<String>) -> Self
pub fn with_application_name(self, name: impl Into<String>) -> Self
Sets the application name.
Sourcepub fn with_option(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_option( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Adds a custom connection option.
Sourcepub fn connect_timeout(&self) -> Option<Duration>
pub fn connect_timeout(&self) -> Option<Duration>
Returns the connection timeout.
Sourcepub fn application_name(&self) -> Option<&str>
pub fn application_name(&self) -> Option<&str>
Returns the application name.
Sourcepub fn startup_params(&self) -> Vec<(&str, &str)>
pub fn startup_params(&self) -> Vec<(&str, &str)>
Returns the startup parameters for the connection.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin 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
Mutably borrows from an owned value. Read more
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request