Skip to main content

Config

Struct Config 

Source
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

Source

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.

Source

pub fn with_host(self, host: impl Into<String>) -> Self

Sets the host.

Source

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

Sets the port.

Source

pub fn with_database(self, database: impl Into<String>) -> Self

Sets the database name.

Source

pub fn with_user(self, user: impl Into<String>) -> Self

Sets the username.

Source

pub fn with_password(self, password: impl Into<String>) -> Self

Sets the password.

Source

pub fn with_connect_timeout(self, timeout: Duration) -> Self

Sets the connection timeout.

Source

pub fn with_application_name(self, name: impl Into<String>) -> Self

Sets the application name.

Source

pub fn with_option( self, name: impl Into<String>, value: impl Into<String>, ) -> Self

Adds a custom connection option.

Source

pub fn host(&self) -> &str

Returns the host.

Source

pub fn port(&self) -> u16

Returns the port.

Source

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

Returns the database name.

Source

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

Returns the username.

Source

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

Returns the password.

Source

pub fn connect_timeout(&self) -> Option<Duration>

Returns the connection timeout.

Source

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

Returns the application name.

Source

pub fn options(&self) -> &[(String, String)]

Returns the connection options.

Source

pub fn startup_params(&self) -> Vec<(&str, &str)>

Returns the startup parameters for the connection.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

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

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

impl Default for Config

Source§

fn default() -> Self

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

impl FromStr for Config

Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a connection string into a Config.

Format: host:port/database?user=xxx&password=xxx

Source§

type Err = String

The associated error which can be returned from parsing.

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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
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, 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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more