#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

#2865 in Rust patterns

Download history 1410/week @ 2023-12-06 1722/week @ 2023-12-13 901/week @ 2023-12-20 631/week @ 2023-12-27 927/week @ 2024-01-03 1395/week @ 2024-01-10 1273/week @ 2024-01-17 1480/week @ 2024-01-24 1276/week @ 2024-01-31 1135/week @ 2024-02-07 1134/week @ 2024-02-14 1017/week @ 2024-02-21 1333/week @ 2024-02-28 1218/week @ 2024-03-06 1108/week @ 2024-03-13 1084/week @ 2024-03-20

5,008 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