Crate serde_multipart

Crate serde_multipart 

Source
Expand description

Serde codec for multipart messages.

Using [serialize] / [deserialize], fields typed Part are extracted from the main payload and appended to a list of parts. Each part is backed by Vec<bytes::Bytes> for cheap, zero-copy sharing.

On decode, the body and its parts are reassembled into the original value without copying.

The on-the-wire form is a Message (body + parts). Your transport sends and receives Messages; the codec reconstructs the value, enabling efficient network I/O without compacting data into a single buffer.

Implementation note: this crate uses Rust’s min_specialization feature to enable the use of Parts with any Serde serializer or deserializer. This feature is fairly restrictive, and thus the API offered by [serialize] / [deserialize] is not customizable. If customization is needed, you need to add specialization implementations for these codecs. See [part::PartSerializer] and [part::PartDeserializer] for details.

Structs§

Frame
An encoded Message frame. Implements [bytes::Buf], and supports vectored writes. Thus, Frame is like a reader of an encoded Message.
Message
A multi-part message, comprising a message body and a list of parts. Messages only contain references to underlying byte buffers and are cheaply cloned.
Part
Part represents a single part of a multipart message. Its type is simple: it is just a newtype of the byte buffer [Bytes], which permits zero copy shared ownership of the underlying buffers. Part itself provides a customized serialization implementation that is specialized for the multipart codecs in this crate, skipping copying the bytes whenever possible.

Functions§

deserialize_bincode
Deserialize a message serialized by [serialize], stitching together the original message without copying the underlying buffers.
serialize_bincode
Serialize the provided value into a multipart message. The value is encoded using an extended version of bincode that skips serializing Parts, which are instead held directly by the returned message.