clickhouse-c-rs provides Rust bindings for
clickhouse-c, a C library for
ClickHouse Native format and native TCP protocol. Clients require ClickHouse 23.3
or newer and advertise protocol revision 54465.
Crate provides three levels of access:
- safe types for reading and writing Native blocks
- blocking and Tokio clients for ClickHouse native TCP protocol
- direct access to C API through
clickhouse_c::sys
Blocking APIs support custom transports through Io. PosixIo supports Unix
file descriptors, including sockets and pipes. IolessClient separates protocol
processing from transport I/O for use with other runtimes. Optional TLS support
uses rustls.
[dependencies]
clickhouse-c-rs = "0.1"Default configuration enables LZ4 compression and requires system liblz4 development files. Disable default features for a build that only requires C compiler and libc:
[dependencies]
clickhouse-c-rs = { version = "0.1", default-features = false }Available features:
| Feature | Description | System requirement |
|---|---|---|
lz4 |
LZ4 compression, enabled by default | liblz4 |
zstd |
Zstandard compression | libzstd |
tokio |
Asynchronous client using Tokio | none |
tls |
Blocking and asynchronous TLS using rustls | none |
Asynchronous TLS requires both tokio and tls.
API documentation is available on
docs.rs. Start with BlockReader and
BlockBuilder for Native block streams, Client for blocking TCP connections,
AsyncClient for Tokio connections, or IolessClient for transport-independent
protocol processing.
Repository includes clickhouse-c as a git submodule. Initialize it before
building from a source checkout:
git submodule update --initSet CHC_INCLUDE_DIR to build against another clickhouse-c checkout.
Library supports Unix platforms. Minimum supported Rust version is 1.85.
Apache-2.0. See clickhouse-c/LICENSE for upstream library license.