PayloadSerializer

Trait PayloadSerializer 

Source
pub trait PayloadSerializer: ShapeSerializer {
    // Required method
    fn finish_boxed(self: Box<Self>) -> Vec<u8> ;
}
Expand description

Object-safe view of a codec’s serializer.

Combines ShapeSerializer with an object-safe finish operation. FinishSerializer::finish takes self by value, which cannot be called through &mut dyn ShapeSerializer — so this trait exposes finish(self: Box<Self>) instead, which is object-safe.

A blanket impl is provided for every ShapeSerializer + FinishSerializer, so every concrete codec serializer (e.g., JsonSerializer) is automatically usable through Box<dyn PayloadSerializer> without requiring codec authors to write extra impls.

Required Methods§

Source

fn finish_boxed(self: Box<Self>) -> Vec<u8>

Consumes this boxed serializer and returns the serialized bytes.

Implementors§