Crate cslice [] [src]

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.

Structs

CMutSlice

A mutable slice, equivalent to &'a mut T.

CSlice

An immutable slice, equivalent to &'a T.

Traits

AsCMutSlice

A cheap conversion to a CMutSlice.

AsCSlice

A cheap conversion to a CSlice.