#abi #string #syscalls #pointers #reference #thin #unix

nightly null-terminated

Library of null-terminated slices and UTF-8-encoded strings with thin references

24 releases

Uses old Rust 2015

0.3.17 Dec 14, 2021
0.3.15 May 26, 2021
0.3.14 Dec 9, 2019
0.3.9 Apr 24, 2019
0.2.6 Dec 22, 2017

#15 in #thin

Download history 177/week @ 2024-06-13 164/week @ 2024-06-20 141/week @ 2024-06-27 68/week @ 2024-07-04 149/week @ 2024-07-11 77/week @ 2024-07-18 148/week @ 2024-07-25 167/week @ 2024-08-01 307/week @ 2024-08-08 481/week @ 2024-08-15 226/week @ 2024-08-22 248/week @ 2024-08-29 219/week @ 2024-09-05 331/week @ 2024-09-12 320/week @ 2024-09-19 259/week @ 2024-09-26

1,230 downloads per month
Used in 9 crates (6 directly)

MIT/Apache

20KB
317 lines

null-terminated

Library of null-terminated slices and UTF-8-encoded strings, references to which are thin pointers for efficiency and ease of use with FFI

The likely primary use cases are C FFI and OS ABI (for example: on Unix, many system calls take, and the initial environment involves, null-terminated arguments).

As the representation is a bare pointer to the element type, one can declare foreign functions which merely take arguments or return values of type Nul<_>, for example:

extern "C" {
    fn strlen(_: &Nul<u8>) -> usize;
    fn strchr(_: &Nul<u8>, _: c_int) -> &Nul<u8>;
}

For further examples, see the docs of Nul.

License: MIT OR Apache-2.0


lib.rs:

Library of null-terminated slices and UTF-8-encoded strings, references to which are thin pointers for efficiency and ease of use with FFI

The likely primary use cases are C FFI and OS ABI (for example: on Unix, many system calls take, and the initial environment involves, null-terminated arguments).

As the representation is a bare pointer to the element type, one can declare foreign functions which merely take arguments or return values of type Nul<_>, for example:

extern "C" {
    fn strlen(_: &Nul<u8>) -> usize;
    fn strchr(_: &Nul<u8>, _: c_int) -> &Nul<u8>;
}

For further examples, see the docs of Nul.

Dependencies

~1.5MB
~36K SLoC