pub struct RawVectorMapper<'a> { /* private fields */ }Expand description
An immutable memory-mapped RawVector.
This is compatible with the serialization format of RawVector.
§Examples
use simple_sds_sbwt::raw_vector::{RawVector, RawVectorMapper, AccessRaw, PushRaw};
use simple_sds_sbwt::serialize::{MemoryMap, MemoryMapped, MappingMode};
use simple_sds_sbwt::serialize;
use std::fs;
let filename = serialize::temp_file_name("raw-vector-mapper");
let width = 29;
let mut original = RawVector::new();
unsafe {
original.push_int(123, width);
original.push_int(456, width);
original.push_int(789, width);
}
serialize::serialize_to(&original, &filename);
let map = MemoryMap::new(&filename, MappingMode::ReadOnly).unwrap();
let mapper = RawVectorMapper::new(&map, 0).unwrap();
assert_eq!(mapper.len(), 3 * width);
unsafe {
assert_eq!(mapper.int(0, width), 123);
assert_eq!(mapper.int(width, width), 456);
assert_eq!(mapper.int(2 * width, width), 789);
}
drop(mapper); drop(map);
fs::remove_file(&filename);Implementations§
Trait Implementations§
Source§impl<'a> AccessRaw for RawVectorMapper<'a>
Available on non-target_family=wasm only.
impl<'a> AccessRaw for RawVectorMapper<'a>
Available on non-
target_family=wasm only.Source§unsafe fn int(&self, bit_offset: usize, width: usize) -> u64
unsafe fn int(&self, bit_offset: usize, width: usize) -> u64
Reads an integer from the container. Read more
Source§unsafe fn word_unchecked(&self, index: usize) -> u64
unsafe fn word_unchecked(&self, index: usize) -> u64
Unsafe version of
AccessRaw::word without bounds checks. Read moreSource§fn is_mutable(&self) -> bool
fn is_mutable(&self) -> bool
Returns
true if the underlying data is mutable. Read moreSource§impl<'a> AsRef<MappedSlice<'a, u64>> for RawVectorMapper<'a>
Available on non-target_family=wasm only.
impl<'a> AsRef<MappedSlice<'a, u64>> for RawVectorMapper<'a>
Available on non-
target_family=wasm only.Source§fn as_ref(&self) -> &MappedSlice<'a, u64>
fn as_ref(&self) -> &MappedSlice<'a, u64>
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl<'a> AsRef<RawVectorMapper<'a>> for IntVectorMapper<'a>
Available on non-target_family=wasm only.
impl<'a> AsRef<RawVectorMapper<'a>> for IntVectorMapper<'a>
Available on non-
target_family=wasm only.Source§fn as_ref(&self) -> &RawVectorMapper<'a>
fn as_ref(&self) -> &RawVectorMapper<'a>
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl<'a> Debug for RawVectorMapper<'a>
impl<'a> Debug for RawVectorMapper<'a>
Source§impl<'a> MemoryMapped<'a> for RawVectorMapper<'a>
Available on non-target_family=wasm only.
impl<'a> MemoryMapped<'a> for RawVectorMapper<'a>
Available on non-
target_family=wasm only.Source§impl<'a> PartialEq for RawVectorMapper<'a>
impl<'a> PartialEq for RawVectorMapper<'a>
impl<'a> Eq for RawVectorMapper<'a>
impl<'a> StructuralPartialEq for RawVectorMapper<'a>
Auto Trait Implementations§
impl<'a> Freeze for RawVectorMapper<'a>
impl<'a> RefUnwindSafe for RawVectorMapper<'a>
impl<'a> Send for RawVectorMapper<'a>
impl<'a> Sync for RawVectorMapper<'a>
impl<'a> Unpin for RawVectorMapper<'a>
impl<'a> UnwindSafe for RawVectorMapper<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more