pub fn encode<T: Serialize + ?Sized>(value: &T) -> Result<Vec<u8>>Expand description
Encode value into a freshly allocated Vec<u8>.
This is the Tier-1 entry point — the one-line surface for the common case. Allocates one buffer sized to fit the encoded value.
§Examples
let bytes = pack_io::encode(&42_u64).unwrap();
let back: u64 = pack_io::decode(&bytes).unwrap();
assert_eq!(back, 42);§Errors
Propagates any error returned by the type’s Serialize implementation.
The built-in primitive and collection impls never error on an in-memory
encoder.