pub async fn pack<T: Encode<Packer>>(
v: T,
dst: &mut BytesMut,
) -> Result<(), <T::Encoder as Encoder<T>>::Error>Expand description
Pack a Encode into a singular byte buffer dst.
All asynchronous values contained in v are awaited and encoded as ready values:
future<T>is encoded asreadyvariant offuture<T>stream<T>is encoded asreadyvariant ofstream<T>containing all elements of the stream
Note, that this function will never complete if any of the asynchronous values contained in
v never resolve, use e.g. tokio::time::timeout to bound the time spent packing.
This function does not verify that all asynchronous values have been written. If a deferred
function returned by an encoder does not write every asynchronous value it is responsible for,
the corresponding pending placeholders are left in dst and unpack will fail.
If this function returns an error, contents of dst are undefined.