tfhe-c-api-dynamic-buffer

This is a helper crate for TFHE-rs (https://crates.io/crates/tfhe) to easily share buffers between C and Rust and make their destruction safe on both sides of the FFI

1 unstable release

0.1.0 Jan 15, 2024

#1209 in Cryptography

25 downloads per month

BSD-3-Clause-Clear

15KB
217 lines

TFHE C API Dynamic Buffer

This is a helper crate for TFHE-rs to manage serialization buffers exchange between C and Rust and make their destruction safe on both sides of the FFI.


lib.rs:

This crate provides a DynamicBuffer struct that allows to easily share a pointer to u8 with C APIs and free that pointer properly by carrying a destructor_callback. In that regard it is carrying a very barebone vtable so that freeing the memory pointed to by the DynamicBuffer is easy either on the C or Rust side.

A From implementation is provided to convert a Vec of u8 into a DynamicBuffer easily, the destructor being populated automatically.

A DynamicBufferView is also provided to indicate that the struct does not own the data and is merely used to share data in a read-only way.

No runtime deps

~0–0.8MB