#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

#1694 in Algorithms

Download history 342/week @ 2024-01-17 298/week @ 2024-01-24 444/week @ 2024-01-31 251/week @ 2024-02-07 419/week @ 2024-02-14 401/week @ 2024-02-21 566/week @ 2024-02-28 493/week @ 2024-03-06 476/week @ 2024-03-13 430/week @ 2024-03-20 421/week @ 2024-03-27 574/week @ 2024-04-03 284/week @ 2024-04-10 310/week @ 2024-04-17 335/week @ 2024-04-24 154/week @ 2024-05-01

1,157 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