pub fn serialize_value_with_shape<S>(
serializer: &mut S,
value: Peek<'_, '_>,
target_shape: &'static Shape,
) -> Result<(), SerializeError<S::Error>>where
S: FormatSerializer,Expand description
Serialize a dynamic value (like facet_value::Value) according to a target shape.
This is the inverse of FormatDeserializer::deserialize_with_shape. It allows serializing
a Value as if it were a typed value matching the shape, without the dynamic value’s
type discriminants.
This is useful for non-self-describing formats like postcard where you want to:
- Parse JSON into a
Value - Serialize it to postcard bytes matching a typed schema
§Arguments
serializer- The format serializer to usevalue- APeekinto a dynamic value type (likefacet_value::Value)target_shape- The shape describing the expected wire format
§Errors
Returns an error if:
- The value is not a dynamic value type
- The value’s structure doesn’t match the target shape