Open a monitor mmap at an explicit directory (for testing).
(dir: &Path)
| 191 | |
| 192 | /// Open a monitor mmap at an explicit directory (for testing). |
| 193 | pub fn open_at(dir: &Path) -> std::io::Result<Self> { |
| 194 | let mmap_path = dir.join(MMAP_FILENAME); |
| 195 | let file = std::fs::OpenOptions::new().read(true).open(&mmap_path)?; |
| 196 | let mmap = unsafe { memmap2::Mmap::map(&file)? }; |
| 197 | Ok(Self { |
| 198 | mmap, |
| 199 | dir: dir.to_path_buf(), |
| 200 | }) |
| 201 | } |
| 202 | |
| 203 | /// Current write index (number of entries ever written). |
| 204 | pub fn write_idx(&self) -> u64 { |