#byte-slice #stdio #iovec #memory-safe #vectored-io

no-std ioslice

no_std I/O slices that are still optionally ABI compatible with std and lbc

11 unstable releases

0.6.0 Mar 18, 2024
0.6.0-alpha.2 Apr 27, 2021
0.5.1 Oct 11, 2020
0.4.0 Sep 15, 2020
0.1.0 Sep 8, 2020

#40 in Windows APIs

Download history 197/week @ 2024-07-29 156/week @ 2024-08-05 98/week @ 2024-08-12 87/week @ 2024-08-19 148/week @ 2024-08-26 79/week @ 2024-09-02 97/week @ 2024-09-09 96/week @ 2024-09-16 129/week @ 2024-09-23 62/week @ 2024-09-30 54/week @ 2024-10-07 88/week @ 2024-10-14 100/week @ 2024-10-21 71/week @ 2024-10-28 95/week @ 2024-11-04 53/week @ 2024-11-11

327 downloads per month
Used in 23 crates (3 directly)

MIT license

84KB
1.5K SLoC

ioslice-rs

Build Status Crates.io Documentation

Provides I/O byte slice types that implement most traits that regular slices implement, and are ABI compatible with struct iovec or WSABUF. Additionally, various utility functions and traits for dealing with uninitialized memory in safe code is also included.


lib.rs:

#![no_std]-friendly wrappers over the std::io::IoSlice and std::io::IoSliceMut, which are shared slices and exclusive slices, respectively, and ABI-compatible with system types for I/O vectors.

Internally, the struct will store the following based on crate features:

  • std - wrapping std::io::IoSlice directly, with accessors for it as well as conversion functions and From impls.
  • libc (and #[cfg(unix)]) - wrapping libc::iovec directly on platforms that support it. A marker is also stored, to safely wrap the raw pointer, and forcing usage of this API to follow the borrow checker rules.
  • (none) - wrapping a regular slice, that may not have the same ABI guarantees as the types from std or libc have.

IoSlice will however implement AsRef<[u8]>, Borrow<[u8]>, and Deref<Target = [u8]> regardless of the features used, so long as the slice is marked as initialized.

Dependencies

~190KB