pub fn encode_packed_decimal_with_scratch(
decimal: &SmallDecimal,
digits: u16,
signed: bool,
scratch: &mut ScratchBuffers,
) -> Result<Vec<u8>>Expand description
Encode a packed decimal (COMP-3) while reusing caller-owned scratch buffers to minimize per-call allocations.
Converts the pre-parsed SmallDecimal to its string representation using
the scratch buffer and then delegates to encode_packed_decimal. Intended
for use on codec hot paths where many records are encoded sequentially with
the same ScratchBuffers instance.
§Arguments
decimal- Pre-parsed decimal value to encodedigits- Number of decimal digits in the field (1-18)signed- Whether the field is signed (true) or unsigned (false)scratch- Reusable scratch buffers for zero-allocation string processing
§Returns
A vector of bytes containing the encoded packed decimal (COMP-3 format).
§Errors
Returns an error when the decimal value cannot be encoded into the
requested packed representation (delegates to encode_packed_decimal).
§See Also
encode_packed_decimal- Underlying packed decimal encoderencode_zoned_decimal_with_scratch- Scratch-based zoned decimal encoderdecode_packed_decimal_to_string_with_scratch- Scratch-based decoder