#slice #abi #interfacing #stable #cc #conversion #c-mut-slice

cslice

A library of slices with a stable ABI for interfacing with C

4 releases (2 breaking)

Uses old Rust 2015

0.3.0 Feb 1, 2017
0.2.0 Feb 1, 2017
0.1.1 May 11, 2016
0.1.0 Apr 5, 2016

#2885 in Rust patterns

Download history 1125/week @ 2024-04-08 1321/week @ 2024-04-15 1414/week @ 2024-04-22 1216/week @ 2024-04-29 1225/week @ 2024-05-06 1477/week @ 2024-05-13 1260/week @ 2024-05-20 1013/week @ 2024-05-27 1207/week @ 2024-06-03 942/week @ 2024-06-10 1304/week @ 2024-06-17 1406/week @ 2024-06-24 875/week @ 2024-07-01 1065/week @ 2024-07-08 1208/week @ 2024-07-15 1372/week @ 2024-07-22

4,586 downloads per month
Used in 8 crates (via helix_runtime)

MIT/Apache

7KB
138 lines

CSlice

This library provides an API like Rust slices, but with a guaranteed ABI for interfacing with C/C++.


lib.rs:

A library of C-slices: slices with a stable ABI for interfacing with C.

This library provides two types, CSlice and CMutSlice, for communicating with C about Rust slices or foreign slice-like data structures. Both types have a stable ABI consisting of exactly two pointer-sized words:

struct {
    void *base;
    size_t len;
}

C-slices and Rust slices are interchangeable, with conversion methods in both directions.

This makes it possible to construct slices from foreign code, as well as to communicate Rust slices to foreign code conveniently.

No runtime deps