#buffer #ffi #tfhe

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

#1346 in Algorithms

Download history 209/week @ 2024-01-15 333/week @ 2024-01-22 436/week @ 2024-01-29 348/week @ 2024-02-05 239/week @ 2024-02-12 380/week @ 2024-02-19 629/week @ 2024-02-26 513/week @ 2024-03-04 504/week @ 2024-03-11 375/week @ 2024-03-18 511/week @ 2024-03-25 385/week @ 2024-04-01 500/week @ 2024-04-08 252/week @ 2024-04-15

1,667 downloads per month
Used in tfhe

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–1MB