Crates.io | chd-capi |
lib.rs | chd-capi |
version | |
source | src |
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 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
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_crc
Enables the verify_block_crc
of the chd
crate to verify decompressed CHD hunks with their internal hash.
chd_core_file
Enables 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_virtio
Enables 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_precache
Enables 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
.