Skip to main content

serialize_into

Function serialize_into 

Source
pub fn serialize_into<T>(dst: impl Writer, src: &T) -> WriteResult<()>
where T: SchemaWrite<DefaultConfig, Src = T> + ?Sized,
Expand description

Serialize a type into the given writer.

Like serialize, but allows the caller to provide their own writer.

ยงPartial writes

This operation is not transactional. If it returns an error, dst may already contain a prefix of the serialized value. Dynamically sized values in particular may discover insufficient capacity only after preceding fields have been written.

If the destination must remain unchanged on failure, serialize into a temporary buffer and copy the result only after serialization succeeds. For a fixed-size destination, callers can instead use serialized_size to check that enough space is available first.