lc_framework_sys/lib.rs
1//! [![CI Status]][workflow] [![MSRV]][repo] [![Latest Version]][crates.io]
2//! [![Rust Doc Crate]][docs.rs] [![Rust Doc Main]][docs]
3//!
4//! [CI Status]: https://img.shields.io/github/actions/workflow/status/juntyr/lc-framework-rs/ci.yml?branch=main
5//! [workflow]: https://github.com/juntyr/lc-framework-rs/actions/workflows/ci.yml?query=branch%3Amain
6//!
7//! [MSRV]: https://img.shields.io/badge/MSRV-1.85.0-blue
8//! [repo]: https://github.com/juntyr/lc-framework-rs
9//!
10//! [Latest Version]: https://img.shields.io/crates/v/lc-framework-sys
11//! [crates.io]: https://crates.io/crates/lc-framework-sys
12//!
13//! [Rust Doc Crate]: https://img.shields.io/docsrs/lc-framework-sys
14//! [docs.rs]: https://docs.rs/lc-framework-sys/
15//!
16//! [Rust Doc Main]: https://img.shields.io/badge/docs-main-blue
17//! [docs]: https://juntyr.github.io/lc-framework-rs/lc_framework_sys
18//!
19//! # lc-framework-sys
20//!
21//! Low-level Rust bindigs to the [LC] compression framework.
22//!
23//! [LC]: https://github.com/burtscher/LC-framework
24
25#![allow(non_upper_case_globals)]
26#![allow(non_camel_case_types)]
27#![allow(non_snake_case)]
28#![allow(missing_docs)]
29#![allow(unsafe_code)]
30
31use std::{
32 ffi::{c_char, c_int, c_longlong, c_short},
33 mem::size_of,
34};
35include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
36
37use lc_framework_src as _;
38
39#[expect(clippy::manual_assert)]
40pub const MAX_STAGES: usize = const {
41 if max_stages < 0 {
42 panic!("max_stages must not be negative");
43 }
44
45 let _: c_int = max_stages;
46
47 if size_of::<c_int>() > size_of::<usize>() {
48 panic!("max_stages might not fit into usize");
49 }
50
51 max_stages as usize
52};
53
54#[expect(clippy::manual_assert)]
55const _: () = const {
56 if CS % 8 != 0 {
57 panic!("CS must be a multiple of 8")
58 }
59};
60
61#[cfg(not(target_endian = "little"))]
62compile_error!("LC framework only supports little-endian systems");
63
64#[expect(clippy::manual_assert)]
65const _: () = const {
66 if size_of::<c_longlong>() != 8 {
67 panic!("long long must be 8 bytes")
68 }
69};
70#[expect(clippy::manual_assert)]
71const _: () = const {
72 if size_of::<c_int>() != 4 {
73 panic!("int must be 4 bytes")
74 }
75};
76#[expect(clippy::manual_assert)]
77const _: () = const {
78 if size_of::<c_short>() != 2 {
79 panic!("short must be 2 bytes")
80 }
81};
82#[expect(clippy::manual_assert)]
83const _: () = const {
84 if size_of::<c_char>() != 1 {
85 panic!("char must be 1 byte")
86 }
87};