Skip to main content

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.

Macros§

part_codec
Implement PartCodec, serde::Serialize, and serde::Deserialize.

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.

Enums§

Error
The type of error returned by typed part operations.

Traits§

PartCodec
Converts a framework type to and from a typed multipart part.

Functions§

deserialize_bincode
Deserialize a message serialized by [serialize], stitching together the original message without copying the underlying buffers.
deserialize_part_codec
Deserialize a value that implements PartCodec.
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.
serialize_part_codec
Serialize a value that implements PartCodec.

Type Aliases§

Result
A specialized result type for typed part operations.