Expand description
§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
Erroris an associated type. This allows each implementor to return its own error type, while avoidingdynorBox. This is consistent with how errors are handled inembedded-hal.- In
std::io, theRead/Writetraits might be blocking or non-blocking (i.e. returningWouldBlockerrors) 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-iospecifiesRead/Writeare always blocking, and adds newReadReady/WriteReadytraits to allow using streams in a non-blocking way.
§Optional Cargo features
std: AddsFromimpls to convert to/fromstd::iostructs.alloc: Adds blanket impls forBox, addsWriteimpl toVec.defmt: Derivedefmt::Formatfromdefmt1.x for enums and structs.
§Minimum Supported Rust Version (MSRV)
This crate is guaranteed to compile on stable Rust 1.81 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
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
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.
Enums§
- Error
Kind - Possible kinds of errors.
- Read
Exact Error - Error returned by
Read::read_exact - Seek
From - Enumeration of possible methods to seek within an I/O object.
- Slice
Write Error - Errors that could be returned by
Writeon&mut [u8]. - Write
FmtError - Error returned by
Write::write_fmt