25 lines
528 B
Rust
Raw Normal View History

2021-08-16 13:36:30 +02:00
use std::sync::Arc;
2021-10-10 22:47:12 +01:00
use memmap2::Mmap;
2021-08-16 13:36:30 +02:00
/// Wrapper around Mmap allowing to virtually clone grenad-chunks
2021-09-02 15:17:52 +02:00
/// in a parallel process like the indexing.
2021-08-16 13:36:30 +02:00
#[derive(Debug, Clone)]
pub struct ClonableMmap {
inner: Arc<Mmap>,
}
impl AsRef<[u8]> for ClonableMmap {
fn as_ref(&self) -> &[u8] {
self.inner.as_ref()
}
}
impl From<Mmap> for ClonableMmap {
fn from(inner: Mmap) -> ClonableMmap {
ClonableMmap { inner: Arc::new(inner) }
}
}
pub type CursorClonableMmap = std::io::Cursor<ClonableMmap>;