docs.rs failed to build closure-ffi-3.0.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
closure-ffi-5.0.1
Provides wrappers around closures which allows them to be called through context-free unsafe bare functions.
Context-free bare functions are not needed very often, as properly designed C APIs typically allow the user to specify an opaque pointer to a context object which will be provided to the function pointer. However, this is not always the case, and may be impossible in less common scenarios, e.g. function hooking for game modding/hacking.
Features
The crate comes with the following feature flags:
Stable
std(default): Usestdfeatures. When this is turned off, the crate is compatible withno_std, although a global allocator must be defined.global_jit_alloc(default): Provides theGlobalJitAllocZST which defers to a global JIT allocator implementation provided either throughdefault_jit_allocfeature or theglobal_jit_alloc!macro.default_jit_alloc(default): Provides a global JIT allocator implementation through thejit-allocator2crate. Note that said crate relies on operating system APIs, so while someno_stdconfigurations are supported, bare metal ones will not be able to use this feature.proc_macros: Provides thebare_hrtbproc macro which is necessary for creating bare functions with signatures that involve higher-kinded lifetimes (i.e.for<'a, ...>statements).
Unstable (require a nightly compiler)
unstable: Enable the use of unstable Rust features for aspects of the crate that benefit from them without causing any API breaks. Unstable features that can cause breaking changes when enabled are gated separately, and also enable this feature.tuple_trait: Adds acore::marker::Tuplebound onFnPtr::Args. This allows downstream crates to easily integrate the library with closure-related nightly features such asunboxed_closuresandfn_traits.c_variadic: Adds partial (no invocation throughcall)FnPtrandFn*Thunkimplementations for variadic functions.coverage: Enables support for the-C instrument-coveragecompiler flag.
Examples
Passing a closure to a C API taking a contextless function pointer:
use ;
// Imagine we have an foreign C API for reigstering and unregistering some callback function.
// Notably, the API does not let the user provide a context object to the callback.
unsafe extern "C"
unsafe extern "C"