rdkafka_sys/
lib.rs

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