Crates.io | rmp-futures |
lib.rs | rmp-futures |
version | 0.3.2 |
source | src |
created_at | 2020-03-19 00:47:02.356366 |
updated_at | 2022-09-13 23:01:28.979499 |
description | Async Rust MessagePack and MessagePack-RPC |
homepage | |
repository | https://github.com/tylerwhall/rmp-futures |
max_upload_size | |
id | 220317 |
size | 156,252 |
Async encode/decode for msgpack and msgpack-rpc. Intended to allow
deterministic memory use, making the client responsible for allocation. Since
msgpack is a streamable format, the ability to serialize on the fly as the
writer becomes writable is exposed. Similarly, the reader can be written to
deal with individual encoded objects as they are encountered in the stream.
No memory allocations are performed in the library unless requested, such as
returning a string as a Rust String
or returning an entire object as a
dynamic rmpv::Value
.
Data types are compatible with rmp and rmpv crates where possible.
Every time some data is read and a decision point is reached, such as reaching the start of a new item, the client gets a new object that represents the state of the stream and only offers operations that are valid at that point. So a client can have a static decoding sequence for an expected message with the storage requirements known up front.
The underlying reader or writer are moved into the decoder or encoder. It is only possible to get ownership back by performing a sequence of valid operations on the parser, each returning a new type with its own set of valid operations. This enforces at compile time that elements are read before processing the next element, and that encoded messsages are well-formed.
Recursive objects yield recursive types. Example data type progression for
reading an array containing one element: [true]
Encode and Decode support dynamic write_value()
and into_value()
functions
that deal with heap-allocated messages. This is easier to use at the cost of
memory, but also allows easier transition from other libraries that use
rmpv::Value
such as rmp-rpc
.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.