embedded_io - Rust (original) (raw)
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
Error
is an associated type. This allows each implementor to return its own error type, while avoidingdyn
orBox
. This is consistent with how errors are handled in embedded-hal.- In
std::io
, theRead
/Write
traits might be blocking or non-blocking (i.e. returningWouldBlock
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
specifiesRead
/Write
are always blocking, and adds newReadReady
/WriteReady
traits to allow using streams in a non-blocking way.
§Optional Cargo features
std
: AddsFrom
impls to convert to/fromstd::io
structs, addsstd::error::Error
impls.alloc
: Adds blanket impls forBox
, addsWrite
impl toVec
.defmt-03
: Derivedefmt::Format
fromdefmt
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
- Apache License, Version 2.0 ( orhttp://www.apache.org/licenses/LICENSE-2.0)
- MIT license ( 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.
Possible kinds of errors.
Error returned by Read::read_exact
Enumeration of possible methods to seek within an I/O object.
Errors that could be returned by Write
on &mut [u8]
.
Error returned by Write::write_fmt
Blocking buffered reader.
Error trait.
Base trait for all IO traits, defining the error type.
Blocking reader.
Get whether a reader is ready.
Blocking seek within streams.
Blocking writer.
Get whether a writer is ready.