feat: 添加前后端交互的示例代码
This commit is contained in:
15
src-tauri/src/services/file.rs
Normal file
15
src-tauri/src/services/file.rs
Normal 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()))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user