| Crates.io | compact-enc-det-sys |
| lib.rs | compact-enc-det-sys |
| version | 0.1.0 |
| created_at | 2025-12-12 14:17:52.900352+00 |
| updated_at | 2025-12-12 14:17:52.900352+00 |
| description | Low-level FFI bindings to the Compact Encoding Detection (CED) C++ library |
| homepage | https://github.com/greenhat616/compact_enc_det_rs |
| repository | https://github.com/greenhat616/compact_enc_det_rs |
| max_upload_size | |
| id | 1981605 |
| size | 1,504,627 |
Low-level FFI bindings to the Compact Encoding Detection (CED) C++ library.
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.
Use compact-enc-det-sys directly only if you need:
For normal encoding detection tasks, use the compact-enc-det crate.
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.
The build happens automatically via build.rs:
libs/compact_enc_detuse compact_enc_det_sys::ced_detect_encoding;
let text = b"Hello, world!";
let result = ced_detect_encoding(
text,
"", // url_hint
"", // http_charset_hint
"", // meta_charset_hint
-1, // encoding_hint
-1, // language_hint
2, // corpus_type (QUERY_CORPUS)
true, // ignore_7bit_mail_encodings
);
println!("Encoding: {}", result.encoding);
println!("MIME name: {}", result.mime_name);
println!("Is reliable: {}", result.is_reliable);
ced_detect_encodingpub fn ced_detect_encoding(
bytes: &[u8],
url_hint: &str,
http_charset_hint: &str,
meta_charset_hint: &str,
encoding_hint: i32,
language_hint: i32,
corpus_type: i32,
ignore_7bit_mail_encodings: bool,
) -> CedResult
CedResultpub struct CedResult {
pub mime_name: String,
pub encoding: i32,
pub bytes_consumed: i32,
pub is_reliable: bool,
}
MIT License - see LICENSE file for details.
The underlying C++ library (google/compact_enc_det) is licensed under the Apache License 2.0.
compact-enc-det - Compact Encoding Detection (CED) C++ library