#io-error #stdio #read #read-write #cursor #alloc #optional

no-std no_std_io

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

4 releases

0.6.0 Jun 11, 2023
0.5.3 Jun 11, 2023
0.5.2 Jun 11, 2023
0.5.1 Jun 11, 2023
0.5.0 Jun 11, 2023

#89 in No standard library

Download history 1781/week @ 2024-07-20 1758/week @ 2024-07-27 2548/week @ 2024-08-03 4467/week @ 2024-08-10 3070/week @ 2024-08-17 4729/week @ 2024-08-24 3750/week @ 2024-08-31 3495/week @ 2024-09-07 2568/week @ 2024-09-14 3951/week @ 2024-09-21 3881/week @ 2024-09-28 2683/week @ 2024-10-05 3913/week @ 2024-10-12 5188/week @ 2024-10-19 6512/week @ 2024-10-26 4861/week @ 2024-11-02

20,946 downloads per month
Used in 31 crates (6 directly)

Apache-2.0 OR MIT

130KB
1.5K SLoC

no-std-io

Actions Status Documentation Minimum Supported Rust Version (MSRV)

Fork

no-std-io 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_io = "0.5"

Add the crate, use the things you would usually want from std::io, but instead from no_std_io::io, and use no_std_io::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, such as BufReader and BufWriter with const generic buffers.

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. (Requires nightly feature)

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

Limitations

  • Using the buffer types currently requires nightly due to the use of const generics.
  • Using copy or the buffer types with std support currently requires nightly due to the initializer API.

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

~250KB