1 个不稳定版本

0.1.0 2024年6月27日

#1013 in 解析器实现

Apache-2.0

505KB
12K SLoC

Swim 序列化的 MessagePack 支持。

为 Swim 序列化系统提供 MessagePack 后端。这包括两部分

示例

use bytes::{BufMut, BytesMut};
use swimos_form::write::StructuralWritable;
use swimos_msgpack::{read_from_msg_pack, MsgPackInterpreter};

let mut buffer = BytesMut::with_capacity(128);
let data = vec!["first".to_owned(), "second".to_owned(), "third".to_owned()];
let mut writer = (&mut buffer).writer();

let interpreter = MsgPackInterpreter::new(&mut writer);
assert!(data.write_with(interpreter).is_ok());

let mut bytes = buffer.split().freeze();
let restored = read_from_msg_pack::<Vec<String>, _>(&mut bytes);

assert_eq!(restored, Ok(data));

依赖项

~8–16MB
~182K SLoC