Skip to main content

f32_to_bytes

Function f32_to_bytes 

Source
pub fn f32_to_bytes(v: &[f32]) -> &[u8] 
Expand description

Convert &[f32] to &[u8] for sqlite-vec storage.

§Safety

This function is sound when the following invariants hold:

  1. f32 has no padding bytes per the Rust reference (https://doc.rust-lang.org/reference/types/numeric.html); [f32] has the same byte representation as [u8; size_of_val(v)].
  2. The returned &[u8] borrows from v; its lifetime is tied to the input slice.
  3. Endianness matches sqlite-vec on supported platforms (x86_64, aarch64 little-endian). Targets with big-endian f32 storage are not supported by sqlite-vec.