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
//! Huffc File IO - File Reading and Writing Utility
//!
//! This module provides efficient file reading and writing using memory-mapped files.
//! It ensures fast data access and modification without excessive system calls.
//!
//! ## Features
//! - Uses `memmap2` for efficient file I/O operations.
//! - Supports reading and writing large files efficiently.
//! - Ensures safe memory mapping with flush operations.
//!
//! ## Usage
//!
//! - Writing to a file:
//! ```rust
//! use huffc::fs::write_file;
//! write_file("output.huff", vec![1, 2, 3, 4, 5]);
//! ```
//!
//! - Reading from a file:
//! ```rust
//! use huffc::fs::read_file;
//! let data = read_file("./tests/resources/input.txt");
//! println!("File contents: {:?}", &data[..]);
//! ```
//!
use ;
use ;
/// Writes a buffer to a file using memory-mapped I/O.
///
/// # Arguments
///
/// * `path` - Path to the file to be written.
/// * `buffer` - Data to be written into the file.
///
/// This function creates or truncates the file, maps it into memory,
/// and writes the data efficiently before flushing changes to disk.
///
/// Reads a file into a memory-mapped buffer.
///
/// # Arguments
///
/// * `path` - Path to the file to be read.
///
/// # Returns
///
/// * `Mmap` - Memory-mapped buffer containing the file contents.
///
/// This function opens a file and maps its contents into memory,
/// allowing efficient access without excessive system calls.
///