Skip to main content

ConnectionBuilder

Struct ConnectionBuilder 

Source
pub struct ConnectionBuilder { /* private fields */ }
Expand description

A builder for creating database connections.

This provides a flexible way to configure a connection with various options like authentication, database creation mode, and transport settings.

§Transport Auto-Detection

The transport is automatically detected from the endpoint URL:

  • https:// or http:// → gRPC transport (read-only)
  • Otherwise → TCP transport (e.g., localhost:7483)

§Example

use hyperdb_api::{ConnectionBuilder, CreateMode, Result};

fn main() -> Result<()> {
    // TCP connection
    let conn = ConnectionBuilder::new("localhost:7483")
        .database("example.hyper")
        .create_mode(CreateMode::CreateIfNotExists)
        .user("myuser")
        .password("mypassword")
        .build()?;
    Ok(())
}
// gRPC connection (auto-detected from URL)
let conn = ConnectionBuilder::new("https://hyper-server.example.com:443")
    .database("example.hyper")
    .build()?;

Implementations§

Source§

impl ConnectionBuilder

Source

pub fn new(endpoint: impl Into<String>) -> Self

Creates a new builder for the given endpoint.

§Arguments
  • endpoint - The server endpoint (host:port).
Source

pub fn database(self, path: impl AsRef<Path>) -> Self

Sets the database path.

Source

pub fn create_mode(self, mode: CreateMode) -> Self

Sets the database creation mode.

Default is CreateMode::DoNotCreate.

Source

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

Sets the username for authentication.

Default is “tableau_internal_user”.

Source

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

Sets the password for authentication.

Source

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

Sets the login timeout.

Source

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

Sets the query timeout.

Queries that exceed this duration will be cancelled automatically. Default is no timeout (queries run until completion).

Source

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

Sets the application name sent to the server.

This appears in server logs and can be used for monitoring.

Source

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

Convenience method to set user and password at once.

Source

pub fn create_new_database(self, database_path: impl AsRef<Path>) -> Self

Convenience method to create a new database.

Source

pub fn create_or_open_database(self, database_path: impl AsRef<Path>) -> Self

Convenience method to create database if it doesn’t exist.

Source

pub fn open_database(self, database_path: impl AsRef<Path>) -> Self

Convenience method to open an existing database.

Source

pub fn transfer_mode(self, mode: TransferMode) -> Self

Sets the transfer mode for gRPC connections.

This setting is ignored for TCP connections.

  • TransferMode::Sync - All results in one response (simple, 100s timeout)
  • TransferMode::Async - Header only, fetch results via GetQueryResult
  • TransferMode::Adaptive - First chunk inline, rest streamed (default, recommended)
§Example
use hyperdb_api::{ConnectionBuilder, CreateMode, Result};
use hyperdb_api::grpc::TransferMode;

fn example() -> Result<()> {
    let conn = ConnectionBuilder::new("https://hyper-server:443")
        .database("example.hyper")
        .transfer_mode(TransferMode::Adaptive)
        .build()?;
    Ok(())
}
Source

pub fn build(self) -> Result<Connection>

Builds and establishes the connection.

The transport is automatically detected from the endpoint URL:

  • https:// or http:// → gRPC transport
  • Otherwise → TCP transport
§Errors

Returns an error if the connection fails or if database creation fails.

Trait Implementations§

Source§

impl Clone for ConnectionBuilder

Source§

fn clone(&self) -> ConnectionBuilder

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 ConnectionBuilder

Source§

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

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

impl Default for ConnectionBuilder

Source§

fn default() -> Self

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

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
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,