feat: 添加前后端交互的示例代码

This commit is contained in:
2024-12-08 02:03:27 +08:00
parent 601b373593
commit f8ec30acfc
24 changed files with 1473 additions and 630 deletions

View File

@@ -0,0 +1,15 @@
use memmap::*;
// TODO: 打开文件,并将文件映射到内存
pub fn mmap_mut_file(file_path: &str) -> Result<MmapMut, std::io::Error> {
let file = std::fs::OpenOptions::new()
.read(true)
.write(true)
.open(file_path)?;
unsafe {
MmapOptions::new()
.map_mut(&file)
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))
}
}