ClientOptions

Struct ClientOptions 

Source
pub struct ClientOptions {
    pub username: String,
    pub password: Secret,
    pub default_database: String,
    pub domain: Option<String>,
    pub ipv4_only: bool,
    pub cafile: Option<PathBuf>,
    pub use_tls: bool,
    pub compression: CompressionMethod,
    pub ext: Extension,
}
Expand description

Configuration options for a ClickHouse client connection and Arrow serialization.

The ClientOptions struct defines the settings used to establish a connection to a ClickHouse server and handle data serialization/deserialization with Apache Arrow. These options are typically set via super::builder::ClientBuilder methods (e.g., super::builder::ClientBuilder::with_username, super::builder::ClientBuilder::with_tls) or constructed directly for use with crate::Client::connect.

§Fields

  • username: The username for authenticating with ClickHouse (default: "default").
  • password: The password for authentication, stored securely as a Secret.
  • default_database: The default database for queries; if empty, uses ClickHouse’s "default" database.
  • domain: Optional domain for TLS verification; inferred from the destination if unset.
  • ipv4_only: If true, restricts address resolution to IPv4; if false, allows IPv6.
  • cafile: Optional path to a certificate authority file for TLS connections.
  • use_tls: If true, enables TLS for secure connections; if false, uses plain TCP.
  • compression: The compression method for data exchange (default: CompressionMethod::LZ4).
  • arrow: Optional Arrow-specific serialization options (see ArrowOptions).
  • cloud: Cloud-specific options for ClickHouse cloud instances (requires cloud feature).

§Examples

use clickhouse_arrow::prelude::*;

let options = ClientOptions {
    username: "admin".to_string(),
    password: Secret::new("secret"),
    default_database: "my_db".to_string(),
    use_tls: true,
    ..ClientOptions::default()
};

let client = Client::connect("localhost:9000", options, None, None)
    .await
    .unwrap();

Fields§

§username: String

Username credential

§password: Secret

Password credential. Secret is used to minimize likelihood of exposure through logs

§default_database: String

Scope this client to a specifc database, otherwise ‘default’ is used

§domain: Option<String>

For tls, provide the domain, otherwise it will be determined from the endpoint.

§ipv4_only: bool

Whether any non-ipv4 socket addrs should be filtered out.

§cafile: Option<PathBuf>

Provide a path to a certificate authority to use for tls.

§use_tls: bool

Whether a connection should be made securely over tls.

§compression: CompressionMethod

The compression to use when sending data to clickhouse.

§ext: Extension

Additional configuration not core to ClickHouse connections

Implementations§

Source§

impl ClientOptions

Source

pub fn new() -> Self

Create a new ClientOptions with default values.

Source

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

Source

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

Source

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

Source

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

Source

pub fn with_ipv4_only(self, ipv4_only: bool) -> Self

Source

pub fn with_cafile<P: AsRef<Path>>(self, cafile: P) -> Self

Source

pub fn with_use_tls(self, use_tls: bool) -> Self

Source

pub fn with_compression(self, compression: CompressionMethod) -> Self

Source

pub fn with_extension(self, ext: Extension) -> Self

Source

pub fn extend(self, ext: impl Fn(Extension) -> Extension) -> Self

Trait Implementations§

Source§

impl Clone for ClientOptions

Source§

fn clone(&self) -> ClientOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ClientOptions

Source§

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

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

impl Default for ClientOptions

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for ClientOptions

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ClientOptions

Source§

fn eq(&self, other: &ClientOptions) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ClientOptions

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ClientOptions

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> 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> 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,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,