Repository: dropbox/rust-brotli (language: rust)

Issue:
Provide Rust only interface
Having the C FFI interface exported via `no_mangle` functions when `brotli` is used as an `rlib` dependency causes issues when linking into a project that also depends on the C `brotli` library (see https://github.com/Nemo157/async-compression/issues/83).

I'm not sure what the best approach for this would be; as someone that has not worked on a library exposing a C ABI, it seems to me that this would work better as a separate crate simply wrapping a Rustic implementation, instead of being combined into a single crate. Another idea I had was putting the `ffi` module behind a cargo feature. But neither of these feel like the perfect solution to me.


Discussion / hints:
wow I never imagined the compatibility would cause issues... I wonder if feature flag is the  best... we can set it on by default?
Mind authoring a patch for it?
Yep, I can take a look.

Fix patch:
diff --git a/Cargo.toml b/Cargo.toml
index ed9b249d..255871f4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -33,7 +33,7 @@ incremental=false
 "sha2" = {version="~0.8", optional=true}
 
 [features]
-default=["std"]
+default=["std", "ffi-api"]
 validation=["sha2"]
 seccomp = ["brotli-decompressor/seccomp"]
 std = ["alloc-stdlib", "brotli-decompressor/std"]
@@ -43,3 +43,4 @@ benchmark = ["brotli-decompressor/benchmark"]
 vector_scratch_space = []
 simd = ["packed_simd/into_bits"]
 pass-through-ffi-panics = []
+ffi-api = []
diff --git a/src/lib.rs b/src/lib.rs
index ff891811..48adb63d 100755
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -52,6 +52,7 @@ pub use enc::input_pair::InputPair;
 pub use enc::interface::SliceOffset;
 pub use enc::interface::thaw;
 pub use enc::interface::thaw_pair;
+#[cfg(feature="ffi-api")]
 pub mod ffi;
 // interface
 // pub fn BrotliDecompressStream(mut available_in: &mut usize,


Test patch: