4 个版本
0.2.0 | 2023年2月6日 |
---|---|
0.1.2 | 2023年1月23日 |
0.1.1 | 2023年1月22日 |
0.1.0 | 2023年1月20日 |
在 嵌入式开发 中排名 #1999
22KB
533 行
emstr
no_std
和 alloc-free 字符串构建和编码,用于 Rust 中的嵌入式固件。
此 crate 为字符串编码提供 EncodeStr
特性,并为基本类型提供实现,同时还有一个 write!
宏,用于从可编码对象构建字符串,大致相当于 alloc::format!
,但使用预先分配的缓冲区。
状态
lib.rs
:
在嵌入式无 std/alloc-free 环境中进行字符串连接/编码/操作的辅助工具
有关基本编码特性,请参阅 [EncodeStr],有关构建字符串的,请参阅 [write!]
// 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");
依赖关系
~94–265KB