Serializes a `T:` [`Serialize`] into a [`Vec `]. Warning:** The format is incompatible with [`decode`][`crate::decode`] and subject to change between major versions.
(t: &T)
| 24 | /// **Warning:** The format is incompatible with [`decode`][`crate::decode`] and subject to |
| 25 | /// change between major versions. |
| 26 | pub fn serialize<T: Serialize + ?Sized>(t: &T) -> Result<Vec<u8>, Error> { |
| 27 | let mut lazy = LazyEncoder::Unspecified { |
| 28 | reserved: NonZeroUsize::new(1), |
| 29 | }; |
| 30 | let mut index_alloc = 0; |
| 31 | t.serialize(EncoderWrapper { |
| 32 | lazy: &mut lazy, |
| 33 | index_alloc: &mut index_alloc, |
| 34 | })?; |
| 35 | Ok(lazy.collect(index_alloc)) |
| 36 | } |
| 37 | } |
| 38 | pub use inner::serialize; |
| 39 |