use memmap2::Mmap;
use std::{fs::File, path::Path};
use crate::error::Result;
pub(super) fn open_mmap(path: &Path, total_bytes: u64) -> Result<Option<Mmap>> {
if total_bytes == 0 {
return Ok(None);
}
let file = File::open(path)?;
Ok(Some(unsafe { Mmap::map(&file) }?))
}
#[doc(hidden)]
pub trait PayloadBuilderOps<T> {
type Store;
fn push(&mut self, payload: T) -> Result<()>;
fn finish(self) -> Result<Self::Store>;
fn finish_persisted(self, payloads_path: &Path, offsets_path: &Path) -> Result<Self::Store>;
}