Skip to main content

blosc_rs_sys/
lib.rs

1//! Unsafe Rust bindings for blosc - a blocking, shuffling and lossless compression library.
2//!
3//! Cargo features enable or disable support for various compression codecs such as `zstd`, `lz4` and `zlib`.
4//! The `blosclz` codec is always supported.
5
6mod c_bridge {
7    #![allow(dead_code)]
8    #![allow(unused_imports)]
9    #![allow(clippy::upper_case_acronyms)]
10    #![allow(clippy::missing_safety_doc)]
11    #![allow(rustdoc::invalid_html_tags)]
12    #![allow(rustdoc::broken_intra_doc_links)]
13    #![allow(missing_docs)]
14    #![allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
15
16    include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
17}
18pub use c_bridge::*;
19
20#[cfg(test)]
21mod tests {
22    #[test]
23    fn check_linking() {
24        let data: [u8; 8] = [1, 2, 3, 4, 5, 6, 7, 8];
25        let mut dest = [0u8; 100];
26        unsafe {
27            crate::blosc_compress_ctx(
28                0,
29                crate::BLOSC_NOSHUFFLE as i32,
30                1,
31                data.len(),
32                data.as_ptr() as *const core::ffi::c_void,
33                dest.as_mut_ptr() as *mut core::ffi::c_void,
34                dest.len(),
35                c"zstd".as_ptr(),
36                0,
37                1,
38            );
39        }
40    }
41}