fn sign_cast_to<const N: usize>(raw: &[u8]) -> Result<[u8; N], ArrowError>
Expand description
Sign-extend or (when larger) validate-and-truncate a big-endian two’s-complement
integer into exactly N
bytes. This matches Avro’s decimal binary encoding:
the payload is a big-endian two’s-complement integer, and when narrowing it must
be representable without changing sign or value.
If raw.len() < N
, the value is sign-extended.
If raw.len() > N
, all truncated leading bytes must match the sign-extension byte
and the MSB of the first kept byte must match the sign (to avoid silent overflow).