Skip to main content

extend_packed_float

Function extend_packed_float 

Source
pub fn extend_packed_float(
    payload: &[u8],
    out: &mut Vec<f32>,
) -> Result<(), DecodeError>
Expand description

Decode an entire packed float payload into out in one pass.

The payload length is validated against the element width up front, so a malformed payload fails with DecodeError::UnexpectedEof — the same error the per-element loop produces at the trailing partial element — and leaves out unmodified rather than partially extended.

from_le_bytes over slice::chunks_exact is endian-correct on every target and compiles to a bulk copy on little-endian ones, which is where the win over the per-element loop comes from: one bounds regime for the whole payload instead of a remaining-bytes check per element.