14个版本
0.6.3 | 2024年3月29日 |
---|---|
0.6.2 | 2023年11月15日 |
0.6.1 | 2023年4月21日 |
0.6.0 | 2023年3月31日 |
0.1.0-ref-compat.0 | 2022年5月29日 |
#954 在 解析器实现
每月67次下载
405KB
11K SLoC
从其公开规范实现Dash7 ALP协议编解码器。
这个库目前主要用于桌面级使用。它大量使用Vec和Box,因此在解码时自行进行内存分配。
状态
当前规范已完全实现。
此库尚未在任何项目中使用,因此可能存在一些错误。
lib.rs
:
从其公开规范实现Dash7 ALP协议解析器。
协议
该协议指定了可以发送到另一个系统进行通信的ALP命令。每个命令都是ALP操作的聚合。
该协议基于这样一个事实:每个通信方都持有Dash7文件系统。因此,对其他设备的每个请求都是由一系列简单的文件系统操作(ALP操作)组成的数组。
关于此库
此库的目标是实现一个规范,重点在于正确性,其次是可用性。性能和内存使用目前被视为次要目标。
快速入门
use dash7_alp::spec::v1_2::{Command, Action, action};
use hex_literal::hex;
let cmd = Command {
actions: vec![
Action::RequestTag(action::RequestTag { id: 66, eop: true }),
Action::ReadFileData(action::ReadFileData {
resp: true,
group: false,
file_id: 0,
offset: 0,
size: 8,
}),
Action::ReadFileData(action::ReadFileData {
resp: false,
group: true,
file_id: 4,
offset: 2,
size: 3,
}),
Action::Nop(action::Nop {
resp: true,
group: true,
}),
],
};
let data = &hex!("B4 42 41 00 00 08 81 04 02 03 C0") as &[u8];
assert_eq!(&cmd.encode()[..], data);
let parsed_cmd = Command::decode(data).expect("should be parsed without error");
assert_eq!(parsed_cmd, cmd);