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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
use crateEntryHandle;
use ;
/// `EntryStream` provides a **streaming interface** over an `EntryHandle`.
///
/// This struct allows **reading large entries in chunks** instead of loading
/// the entire entry into memory. It is useful when working with entries larger
/// than available RAM.
///
/// # ⚠️ **Non Zero-Copy Warning**
/// Unlike `EntryHandle`, this implementation **performs memory copies**.
/// Each call to `read()` copies a portion of the entry into a user-provided buffer.
///
/// **For zero-copy access**, use `EntryHandle::as_slice()` instead.
///
/// # Example Usage
/// ```rust
/// use simd_r_drive::storage_engine::{DataStore, EntryHandle, EntryStream};
/// use std::io::Read;
/// use std::path::PathBuf;
///
/// let data_store = DataStore::from(PathBuf::from("test_storage.bin"));
///
/// // Write some test data
/// data_store.write(b"test_key", b"test_data");
/// let entry_handle = data_store.read(b"test_key").unwrap();
///
/// // Assume `entry_handle` is obtained from storage
/// let mut stream = EntryStream::from(entry_handle);
///
/// let mut buffer = vec![0; 4096]; // Read in 4KB chunks
/// while let Ok(bytes_read) = stream.read(&mut buffer) {
/// if bytes_read == 0 {
/// break; // EOF
/// }
/// // Replace this with actual processing logic
/// println!("Read {} bytes", bytes_read);
/// }
/// ```