#io #read-write #core

no-std acid_io

A pared-down version of std::io usable with no_std

1 unstable release

0.1.0 Jan 10, 2022

#118 in No standard library

Download history 254/week @ 2023-12-15 164/week @ 2023-12-22 198/week @ 2023-12-29 190/week @ 2024-01-05 292/week @ 2024-01-12 263/week @ 2024-01-19 276/week @ 2024-01-26 245/week @ 2024-02-02 256/week @ 2024-02-09 273/week @ 2024-02-16 210/week @ 2024-02-23 211/week @ 2024-03-01 174/week @ 2024-03-08 256/week @ 2024-03-15 324/week @ 2024-03-22 283/week @ 2024-03-29

1,088 downloads per month
Used in 16 crates (4 directly)

MIT/Apache

305KB
4.5K SLoC

acid_io

A pared-down version of Rust's std::io usable in no_std contexts.


Rust's std::io provides common interfaces that are used widely in the Rust ecosystem for reading and writing data. However, as of 2022, these interfaces are not available in no_std builds.

This crate provides drop-in replacements for the types and traits exposed by std::io which can be used with no_std.

Example

#![no_std]

use acid_io::{
    byteorder::{BE, LE, ReadBytesExt, WriteBytesExt},
    Cursor, Read, Seek, SeekFrom, Write,
};

let mut buf = [0u8; 10];
let mut curs = Cursor::new(&mut buf);

curs.write_u8(1)?;
curs.write_u16::<BE>(2)?;
curs.write_u32::<LE>(3)?;

curs.seek(SeekFrom::Start(0))?;

assert_eq!(curs.read_u8()?, 1);
assert_eq!(curs.read_u16::<BE>()?, 2);
assert_eq!(curs.read_u32::<LE>()?, 3);

Feature flags

  • std

    Replaces all items with re-exports of their counterparts in std::io. This effectively makes acid_io an alias of std::io, but missing any items that acid_io wouldn't otherwise provide.

  • alloc

    Exposes BufReader and BufWriter, as well as those trait methods which take or return Vec or String.

  • byteorder

    Exposes acid_io::byteorder, which contains implementations of ReadBytesExt and WriteBytesExt for acid_io's Read and Write traits. Also re-exports the rest of byteorder.

Acknowledgments

Much of this library is copied verbatim or with slight modifications from other Rust projects:

If you find this crate useful, please consider sponsoring members of the Library team on GitHub.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0.2–43MB
~583K SLoC