Create a mapped value from a byte slice
(data: &[u8], config: &MemoryMappedConfig)
| 67 | impl MappedValue { |
| 68 | /// Create a mapped value from a byte slice |
| 69 | pub fn from_slice(data: &[u8], config: &MemoryMappedConfig) -> io::Result<Self> { |
| 70 | if data.len() < config.min_size_for_mmap || data.len() <= config.max_memory_size { |
| 71 | // Store in memory for small values |
| 72 | Ok(MappedValue::Memory(data.to_vec())) |
| 73 | } else { |
| 74 | // Create temporary file and memory map it |
| 75 | Self::create_temp_mapped(data, config) |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | /// Create a mapped value from a static reference (zero-copy) |
| 80 | pub fn from_static(data: &'static [u8]) -> Self { |