compact-enc-det-sys
Low-level FFI bindings to the Compact Encoding Detection (CED) C++ library.
Overview
This crate provides unsafe FFI bindings to Google's Compact Encoding Detection library using cxx. For most use cases, you should use the high-level compact-enc-det crate instead, which provides a safe and ergonomic Rust API.
When to Use This Crate
Use compact-enc-det-sys directly only if you need:
- Direct access to the C++ API
- Custom build configurations
- To build your own higher-level wrapper
For normal encoding detection tasks, use the compact-enc-det crate.
Building
This crate uses cxx and cxx-build to generate bindings and compile the C++ library. The C++ source code is included as a git submodule.
Prerequisites
- Rust 1.70+
- A C++ compiler (GCC, Clang, or MSVC)
- CMake (optional, for standalone C++ builds)
Build Process
The build happens automatically via build.rs:
- The C++ library is compiled from source in
libs/compact_enc_det - CXX generates the Rust-C++ bridge code
- Everything is linked together
Usage
use ced_detect_encoding;
let text = b"Hello, world!";
let result = ced_detect_encoding;
println!;
println!;
println!;
API
ced_detect_encoding
CedResult
License
MIT License - see LICENSE file for details.
The underlying C++ library (google/compact_enc_det) is licensed under the Apache License 2.0.
See Also
compact-enc-det- Compact Encoding Detection (CED) C++ library- CXX - Safe interop between Rust and C++