| Crates.io | chd-capi |
| lib.rs | chd-capi |
| version | 0.3.1 |
| created_at | 2022-08-02 22:19:57.129183+00 |
| updated_at | 2025-04-01 22:21:59.801962+00 |
| description | libchdr-compatible C API for a Rust implementation of the CHD File Format |
| homepage | |
| repository | https://github.com/SnowflakePowered/chd-rs |
| max_upload_size | |
| id | 637594 |
| size | 77,279 |
chd-capi⚠️The C API has not been heavily tested. Use at your own risk. ⚠️
chd-rs provides a C API compatible with chd.h.
ABI compatibility is detailed below but is untested when compiling as a dynamic library. The intended consumption for this crate is not via cargo, but by vendoring
the sources of the C API in tree, along with a compatible libchdcorefile implementation
for your platform.
verify_block_crcEnables the verify_block_crc of the chd crate to verify decompressed CHD hunks with their internal hash.
chd_core_fileEnables core_file* and thechd_open_file, and chd_core_file APIs. This feature requires a libchdcorefile implementation,
or the default POSIX compatible implementation (where core_file* is FILE*) will be used.
Note that by default, core_file* is not an opaque pointer and is a C FILE* stream. This allows the underlying
file pointer to be changed unsafely beneath the memory safety guarantees of chd-rs. We strongly encourage using
chd_open instead of chd_open_file.
If you need core_file* support, chd-capi should have the chd_core_file feature enabled, which will wrap
FILE* to be usable in Rust with a lightweight wrapper in libchdcorefile. If the default implementation
is not suitable, you may need to implement libchdcorefile yourself. The chd_core_file feature requires
CMake and Clang to be installed.
chd_virtioEnables the virtual I/O functions chd_open_core_file.
Because this C API requires core_file to be an opaque pointer, there is no difference between chd_open_file and
chd_open_core_file unlike libchdr, and chd_open_core_file is simply an alias for chd_open_file. All functions that
take core_file* require a libchdcorefile implementation.
chd_precacheEnables precaching of the underlying file into memory with the chd_precache_progress and chd_precache functions.
chd-rs makes the following ABI-compatibility guarantees compared to libchdr when compiled statically.
chd_error is ABI and API-compatible with chd.hchd_header is ABI and API-compatible chd.hchd_file * is an opaque pointer. It is not layout compatible with chd.ccore_file * is user-defined when the chd_core_file feature is enabled.free is undefined behaviour. The exception are chd_file * pointers which can be safely freed with chd_close.