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, andserde::Deserialize.
Structs§
- Frame
- An encoded
Messageframe. Implements [bytes::Buf], and supports vectored writes. Thus,Frameis like a reader of an encodedMessage. - 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§
- Part
Codec - 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
bincodethat skips serializingParts, 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.