7 releases (4 breaking)

0.6.1 Oct 22, 2023
0.6.0 Oct 3, 2023
0.5.0 Aug 7, 2023
0.4.0 Nov 25, 2022
0.1.0 May 6, 2022

#520 in Embedded development

Download history 43359/week @ 2023-12-12 34170/week @ 2023-12-19 24769/week @ 2023-12-26 41093/week @ 2024-01-02 46768/week @ 2024-01-09 45777/week @ 2024-01-16 50077/week @ 2024-01-23 46420/week @ 2024-01-30 47554/week @ 2024-02-06 51768/week @ 2024-02-13 52969/week @ 2024-02-20 53531/week @ 2024-02-27 61465/week @ 2024-03-05 57627/week @ 2024-03-12 58066/week @ 2024-03-19 42257/week @ 2024-03-26

228,393 downloads per month
Used in 332 crates (47 directly)

MIT/Apache

31KB
459 lines

crates.io crates.io Documentation

embedded-io

This project is developed and maintained by the HAL team.

Input/Output traits for embedded systems.

Rust's std::io traits are not available in no_std targets, mainly because std::io::Error requires allocation. This crate contains replacement equivalent traits, usable in no_std targets.

Differences with std::io

  • Error is an associated type. This allows each implementor to return its own error type, while avoiding dyn or Box. This is consistent with how errors are handled in embedded-hal.
  • In std::io, the Read/Write traits might be blocking or non-blocking (i.e. returning WouldBlock errors) depending on the file descriptor's mode, which is only known at run-time. This allows passing a non-blocking stream to code that expects a blocking stream, causing unexpected errors. To solve this, embedded-io specifies Read/Write are always blocking, and adds new ReadReady/WriteReady traits to allow using streams in a non-blocking way.

Optional Cargo features

  • std: Adds From impls to convert to/from std::io structs, adds std::error::Error impls.
  • alloc: Adds blanket impls for Box, adds Write impl to Vec.
  • defmt-03: Derive defmt::Format from defmt 0.3 for enums and structs.

Minimum Supported Rust Version (MSRV)

This crate is guaranteed to compile on stable Rust 1.60 and up. It might compile with older versions but that may change in any new patch release.

See here for details on how the MSRV may be upgraded.

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

~165KB