Function try_encode

Source
pub fn try_encode(
    source: &[u8],
    dest: &mut [u8],
) -> Result<usize, DestBufTooSmallError>
Expand description

Attempts to encode the source buffer into the dest buffer.

This function assumes the typical sentinel value of 0, but does not terminate the encoded message with the sentinel value. This should be done by the caller to ensure proper framing.

ยงReturns

The number of bytes written to in the dest buffer.

If the destination buffer does not have enough room, an error will be returned.