4 releases
0.2.0 | Feb 6, 2023 |
---|---|
0.1.2 | Jan 23, 2023 |
0.1.1 | Jan 22, 2023 |
0.1.0 | Jan 20, 2023 |
#2088 in Embedded development
63 downloads per month
22KB
533 lines
emstr
no_std
and alloc-free string building and encoding for embedded firmware in rust.
This crate provides an EncodeStr
trait for string encoding and implementations for basic types, as well as a write!
macro for building strings from encodable objects, roughly equivalent to alloc::format!
except using pre-allocated buffers.
Status
lib.rs
:
Helpers for string concatenation / encoding / manipulation in an embedded no_std / alloc free environment
See [EncodeStr] for the base encode trait, and [write!] for constructing strings
// context can be any types implementing [emstr::EncodeStr]
let name = "something";
let progress = 15u8;
// use [emstr::write!]` macro to concatentate encodable types into `buff`
let mut buff = [0u8; 32];
let n = emstr::write!(&mut buff[..], name, ' ', progress, '/', 100u8).unwrap();
// creating the expected output
assert_eq!(&buff[..n], b"something 15/100");
Dependencies
~94–255KB