embedded-io-cursor
A no_std
-compatible Cursor implementation designed for use with embedded-io
.
This crate provides a Cursor
type that wraps an in-memory buffer and provides Read
, Write
, Seek
, and BufRead
implementations using the embedded-io
traits. Unlike the standard library's Cursor
, this implementation works in no_std
environments while maintaining API compatibility where possible.
Usage
Add this to your Cargo.toml
:
[]
= "0.1.0"
Basic Usage
use ;
use Cursor;
// Reading from a static buffer
let mut cursor = new;
let mut buf = ;
cursor.read_exact.unwrap;
assert_eq!;
// Writing to a mutable buffer
let mut buffer = ;
assert_eq!;
With alloc
feature (requires alloc
feature to be enabled)
#
Features
default
: No additional features enabledstd
: Enable standard library support (impliesalloc
)alloc
: Enable support forVec<u8>
andBox<[u8]>
defmt
: Enabledefmt
formatting support
Differences from std::io::Cursor
This implementation maintains API compatibility with std::io::Cursor
where possible, but has some key differences:
- Uses
embedded-io
traits: Instead ofstd::io
traits, this uses theembedded-io
equivalents - Full
BufRead
support: Implementsembedded-io::BufRead
withfill_buf()
andconsume()
- Limited buffer types in
no_std
: Withoutalloc
, only basic slice types are supported - Error type: Uses
embedded_io::ErrorKind
instead ofstd::io::Error
Testing
Run tests with:
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.