#io-error #stdio #embedded-io #read #alloc #read-write #traits

no-std no_std_io2

The bare essentials of std::io for use in no_std. Alloc support is optional.

3 unstable releases

0.9.0 Jan 4, 2025
0.8.1 Oct 12, 2024
0.8.0 Sep 2, 2024

#42 in No standard library

Download history 1208/week @ 2024-11-02 1348/week @ 2024-11-09 1280/week @ 2024-11-16 1516/week @ 2024-11-23 1247/week @ 2024-11-30 1908/week @ 2024-12-07 1539/week @ 2024-12-14 1709/week @ 2024-12-21 1261/week @ 2024-12-28 2303/week @ 2025-01-04 2299/week @ 2025-01-11 2336/week @ 2025-01-18 1800/week @ 2025-01-25 1756/week @ 2025-02-01 2151/week @ 2025-02-08 712/week @ 2025-02-15

6,762 downloads per month
Used in 15 crates (3 directly)

Apache-2.0 OR MIT

125KB
1.5K SLoC

no-std-io

github crates.io docs.rs build status

Fork

no-std-io2 is a fork of no-std-io, which is a fork of core2.

Overview

Ever wanted a Cursor or the Error trait in no_std? Well now you can have it. A 'fork' of Rust's std modules for no_std environments, with the added benefit of optionally taking advantage of alloc.

The goal of this crate is to provide a stable interface for building I/O and error trait functionality in no_std environments. The current code corresponds to the most recent stable API of Rust 1.56.0. It is also a goal to achieve a true alloc-less experience, with opt-in alloc support.

This crate works on stable with some limitations in functionality, and nightly without limitations by adding the relevant feature flag.

This crate is std by default -- use no default features to get no_std mode.

Usage

[dependencies]
no_std_io2 = "0.8"

Add the crate, use the things you would usually want from std::io, but instead from no_std_io2::io, and use no_std_io2::error::Error in place of std::error::Error.

Features

  • std: enables std pass-throughs for the polyfilled types, but allows accessing the new types
  • alloc: enable aspects of the Read and Write traits that require alloc support (WIP)
  • nightly: enables nightly-only features.

Differences to std::io

  • No std::io::Error, so we have our own copy without any Os error functions
  • IoSlice and the *_vectored family of functions are not implemented.
  • BufReader and BufWriter have a different signature, as they now use a const generic bounded array for the internal buffer.

Other than items perhaps being entirely missing or certain functions unavailable on some traits, no function signatures have been changed.

Limitations

  • Error trait is not implemented for ! because never_type feature is not yet stabilized.

License

Licensed under either of

at your option.


Almost all of the code in this repository is a copy of the Rust language codebase with minor modifications.

For attributions, see https://thanks.rust-lang.org/.

Dependencies

~245KB