pub fn serialize(obj: &Object) -> Result<Vec<u8>, MkitError>Expand description
Serialize an Object to its canonical byte form. Allocates fresh
each call; the result is fully owned.
Returns MkitError::OversizePayload if any length-prefixed field
exceeds the wire-format u32 cap, and MkitError::InvalidIdentity
if the object carries a structurally invalid Identity.
ยงCaller precondition: ordering
The writer does not reorder or validate entry/source ordering โ it
encodes them verbatim โ but deserialize enforces a strict
ascending order (Tree entries by name, Remix sources by
(upstream_id, commit_hash)). An Object built by hand with
out-of-order Tree::entries or Remix::sources will therefore
serialize cleanly yet fail to round-trip (deserialize rejects it
with InvalidEntryOrder / InvalidSourceOrder). Callers that bypass
the ordered-building helpers MUST ensure Tree::is_sorted /
Remix::sources_sorted hold before serializing โ otherwise the
resulting (possibly signed) bytes are undecodable.