1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Vector to bytes conversion utilities for storage.
//!
//! Provides safe conversion between `&[f32]` vectors and `&[u8]` byte slices
//! for persistence in memory-mapped storage.
//!
//! # Safety (EPIC-032/US-001)
//!
//! - `vector_to_bytes`: Safe because f32 has no invalid bit patterns
//! - `bytes_to_vector`: Safe because it copies bytes into a new aligned `Vec<f32>`
//! using `ptr::copy_nonoverlapping`, which doesn't require source alignment
/// Converts a vector slice to a byte slice.
///
/// # Safety
///
/// This is safe because:
/// - f32 has no invalid bit patterns
/// - The slice layout is well-defined
/// - The lifetime of the returned slice is tied to the input
pub
/// Converts bytes back to a vector.
///
/// # Arguments
///
/// * `bytes` - Raw bytes to convert (must be at least `dimension * 4` bytes)
/// * `dimension` - Expected vector dimension
///
/// # Returns
///
/// A new `Vec<f32>` containing the converted data.
///
/// # Panics
///
/// Panics if `bytes.len() < dimension * size_of::<f32>()`.
pub