pub fn encode<T: Document>(doc: &T, collection_id: u32) -> Result<Vec<u8>>Expand description
Encode doc into the on-disk record format.
Layout: DocumentHeader (16 bytes) followed by
postcard::to_allocvec(doc). Returns the assembled bytes in a
fresh Vec<u8>; allocation is unavoidable here because the
payload length is not known until postcard runs.
§Errors
Error::Codecif postcard encoding fails.Error::DocumentTooLargeif the resulting record exceedsMAX_INLINE_DOC— overflow chains for oversize records are deferred to a later format-minor (seedocs/format.md§ Document records).