Crate swimos_msgpack

Crate swimos_msgpack 

Source
Expand description

MessagePack support for Swim serialization.

Provides a MessagesPack backend for the Swim serialization system. This consists of two parts:

§Examples

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));

Structs§

MsgPackInterpreter
StructuralWriter implementation that uses the MessagePack format. Primitive values are written with the corresponding MessagePack types. Big integers are written as MessagePack extensions as raw bytes in big endian order. Strings and binary blobs are written as MessagePack string and bin values. Records have the following encoding.

Enums§

MsgPackReadError
Reading MessagePack data can fail if the bytes do not constitute valid MessagePack or the buffer contains an incomplete record.
MsgPackWriteError
Writing out to MessagePack can fail because of an IO error or because a value exceeds the limitations of the MessagePack format.

Functions§

read_from_msg_pack
Attempt to read a StructuralReadable type from MessagePack data in a buffer.