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://orhttp://→ 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
impl ConnectionBuilder
Sourcepub fn new(endpoint: impl Into<String>) -> Self
pub fn new(endpoint: impl Into<String>) -> Self
Creates a new builder for the given endpoint.
§Arguments
endpoint- The server endpoint (host:port).
Sourcepub fn create_mode(self, mode: CreateMode) -> Self
pub fn create_mode(self, mode: CreateMode) -> Self
Sets the database creation mode.
Default is CreateMode::DoNotCreate.
Sourcepub fn user(self, user: impl Into<String>) -> Self
pub fn user(self, user: impl Into<String>) -> Self
Sets the username for authentication.
Default is “tableau_internal_user”.
Sourcepub fn password(self, password: impl Into<String>) -> Self
pub fn password(self, password: impl Into<String>) -> Self
Sets the password for authentication.
Sourcepub fn login_timeout(self, timeout: Duration) -> Self
pub fn login_timeout(self, timeout: Duration) -> Self
Sets the login timeout.
Sourcepub fn query_timeout(self, timeout: Duration) -> Self
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).
Sourcepub fn application_name(self, name: impl Into<String>) -> Self
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.
Sourcepub fn auth(self, user: impl Into<String>, password: impl Into<String>) -> Self
pub fn auth(self, user: impl Into<String>, password: impl Into<String>) -> Self
Convenience method to set user and password at once.
Sourcepub fn create_new_database(self, database_path: impl AsRef<Path>) -> Self
pub fn create_new_database(self, database_path: impl AsRef<Path>) -> Self
Convenience method to create a new database.
Sourcepub fn create_or_open_database(self, database_path: impl AsRef<Path>) -> Self
pub fn create_or_open_database(self, database_path: impl AsRef<Path>) -> Self
Convenience method to create database if it doesn’t exist.
Sourcepub fn open_database(self, database_path: impl AsRef<Path>) -> Self
pub fn open_database(self, database_path: impl AsRef<Path>) -> Self
Convenience method to open an existing database.
Sourcepub fn transfer_mode(self, mode: TransferMode) -> Self
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 viaGetQueryResultTransferMode::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(())
}Sourcepub fn build(self) -> Result<Connection>
pub fn build(self) -> Result<Connection>
Builds and establishes the connection.
The transport is automatically detected from the endpoint URL:
https://orhttp://→ 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
impl Clone for ConnectionBuilder
Source§fn clone(&self) -> ConnectionBuilder
fn clone(&self) -> ConnectionBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConnectionBuilder
impl Debug for ConnectionBuilder
Auto Trait Implementations§
impl Freeze for ConnectionBuilder
impl RefUnwindSafe for ConnectionBuilder
impl Send for ConnectionBuilder
impl Sync for ConnectionBuilder
impl Unpin for ConnectionBuilder
impl UnsafeUnpin for ConnectionBuilder
impl UnwindSafe for ConnectionBuilder
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§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>
T in a tonic::Request