rdkafka2_sys/
lib.rs

1//! Low level bindings to [librdkafka](https://github.com/confluentinc/librdkafka),
2//! a C library for the [Apache Kafka] protocol with producer, consumer, and
3//! admin clients.
4//!
5//! ## Version
6//!
7//! The rdkafka2-sys version number is in the format `X.Y.Z+RX.RY.RZ`, where
8//! `X.Y.Z` is the version of this crate and follows SemVer conventions, while
9//! `RX.RY.RZ` is the version of the bundled librdkafka.
10//!
11//! ## Build
12//!
13//! ### Known issues
14//!
15//! * When any of librdkafka's optional dependencies are enabled, like libz or
16//!   OpenSSL, if you have multiple versions of that library installed upon your
17//!   system, librdkafka's build system may disagree with Cargo about which
18//!   version of the library to use! **This can result in subtly broken
19//!   builds,** if librdkafka compiles against the headers for one version but
20//!   Cargo links against a different version.  For complete confidence when
21//!   building release binaries, use an environment like a Docker container or a
22//!   chroot jail where you can guarantee that only one version of each
23//!   dependency is present. The current design of Cargo unfortunately makes
24//!   this nearly impossible to fix.
25//!
26//! * Windows is only supported when using the CMake build system via the
27//!   `cmake-build` Cargo feature.
28//!
29//! ### Features
30//!
31//! By default a submodule with the librdkafka sources will be used to compile
32//! and statically link the library.
33//!
34//! The **`cmake-build`** feature builds librdkafka with its [CMake] build
35//! system, rather than its default [mklove]-based build system. This feature
36//! requires that CMake is installed on the build machine.
37//!
38//! The **`dynamic-linking`** feature can be used to link rdkafka to a locally
39//! installed version of librdkafka: if the feature is enabled, the build script
40//! will use `pkg-config` to check the version of the library installed in the
41//! system, and it will configure the compiler to dynamically link against it.
42//! The system version of librdkafka must exactly match the version of
43//! librdkafka bundled with this crate.
44//!
45//! The following features directly correspond to librdkafka features (i.e.,
46//! flags you would pass to `configure` if you were compiling manually).
47//!
48//!   * The **`ssl`** feature enables SSL support. By default, the system's
49//!     OpenSSL library is dynamically linked, but static linking of the version
50//!     bundled with the [openssl-sys] crate can be requested with the
51//!     `ssl-vendored` feature.
52//!   * The **`gssapi`** feature enables SASL GSSAPI support with Cyrus
53//!     libsasl2. By default the system's libsasl2 is dynamically linked, but
54//!     static linking of the version bundled with the [sasl2-sys] crate can be
55//!     requested with the `gssapi-vendored` feature.
56//!   * The **`libz`** feature enables support for zlib compression. This
57//!     feature is enabled by default. By default, the system's libz is
58//!     dynamically linked, but static linking of the version bundled with the
59//!     [libz-sys] crate can be requested with the `libz-static` feature.
60//!   * The **`curl`** feature enables the HTTP client via curl. By default, the
61//!     system's curl is dynamically linked, but static linking of the version
62//!     bundled with the [curl-sys] create can be requested with the
63//!     `curl-static` feature.
64//!   * The **`zstd`** feature enables support for ZSTD compression. By default,
65//!     this builds and statically links the version bundled with the [zstd-sys]
66//!     crate, but dynamic linking of the system's version can be requested with
67//!     the `zstd-pkg-config` feature.
68//!   * The **`external-lz4`** feature statically links against the copy of
69//!     liblz4 bundled with the [lz4-sys] crate. By default, librdkafka
70//!     statically links against its own bundled version of liblz4. Due to
71//!     limitations with lz4-sys, it is not yet possible to dynamically link
72//!     against the system's version of liblz4.
73//!
74//! The `libz` and `cmake-build` features are enabled by default.
75//! The build process is defined in [`build.rs`].
76//!
77//! [`build.rs`]: https://github.com/amountainram/rdkafka2-sys/tree/master/build.rs
78//! [Apache Kafka]: https://kafka.apache.org
79//! [CMake]: https://cmake.org
80//! [libz-sys]: https://crates.io/crates/libz-sys
81//! [curl-sys]: https://crates.io/crates/curl-sys
82//! [lz4-sys]: https://crates.io/crates/lz4-sys
83//! [mklove]: https://github.com/edenhill/mklove
84//! [openssl-sys]: https://crates.io/crates/openssl-sys
85//! [sasl2-sys]: https://docs.rs/sasl2-sys
86//! [zstd-sys]: https://crates.io/crates/zstd-sys
87
88#[cfg(feature = "openssl-sys")]
89extern crate openssl_sys;
90
91#[cfg(feature = "sasl2-sys")]
92extern crate sasl2_sys;
93
94#[cfg(feature = "libz-sys")]
95extern crate libz_sys;
96
97#[cfg(any(feature = "curl-sys", feature = "curl-static"))]
98extern crate curl_sys;
99
100#[cfg(feature = "zstd-sys")]
101extern crate zstd_sys;
102
103#[cfg(feature = "lz4-sys")]
104extern crate lz4_sys;
105
106pub use bindings::*;
107pub use types::*;
108
109/// FFI bindings.
110///
111/// These bindings are automatically generated
112/// with [bindgen](https://github.com/rust-lang/rust-bindgen).
113#[allow(
114    non_camel_case_types,
115    non_upper_case_globals,
116    non_snake_case,
117    clippy::all
118)]
119pub mod bindings;
120/// Enums and structs porting to Rust.
121pub mod types;