IntVectorMapper

Struct IntVectorMapper 

Source
pub struct IntVectorMapper<'a> { /* private fields */ }
Expand description

An immutable memory-mapped IntVector.

This is compatible with the serialization format of IntVector.

§Examples

use simple_sds_sbwt::int_vector::{IntVector, IntVectorMapper};
use simple_sds_sbwt::ops::{Vector, Access};
use simple_sds_sbwt::serialize::{MemoryMap, MemoryMapped, MappingMode};
use simple_sds_sbwt::serialize;
use std::fs;

let filename = serialize::temp_file_name("int-vector-mapper");
let mut v = IntVector::with_len(3, 13, 0).unwrap();
v.set(0, 123); v.set(1, 456); v.set(2, 789);
serialize::serialize_to(&v, &filename);

let map = MemoryMap::new(&filename, MappingMode::ReadOnly).unwrap();
let mapper = IntVectorMapper::new(&map, 0).unwrap();
assert_eq!(mapper.len(), v.len());
for i in 0..mapper.len() {
    assert_eq!(mapper.get(i), v.get(i));
}

drop(mapper); drop(map);
fs::remove_file(&filename).unwrap();

Trait Implementations§

Source§

impl<'a> Access<'a> for IntVectorMapper<'a>

Available on non-target_family=wasm only.
Source§

type Iter = AccessIter<'a, IntVectorMapper<'a>>

Iterator over the items in the vector.
Source§

fn get(&self, index: usize) -> <Self as Vector>::Item

Returns an item from the vector. Read more
Source§

fn iter(&'a self) -> Self::Iter

Returns an iterator over the items in the vector. Read more
Source§

fn get_or( &self, index: usize, value: <Self as Vector>::Item, ) -> <Self as Vector>::Item

Returns an item from the vector or the provided value if index is invalid. Read more
Source§

fn is_mutable(&self) -> bool

Returns true if the underlying data is mutable. Read more
Source§

fn set(&mut self, _: usize, _: <Self as Vector>::Item)

Sets an item in the vector. Read more
Source§

impl<'a> AsRef<RawVectorMapper<'a>> for IntVectorMapper<'a>

Available on non-target_family=wasm only.
Source§

fn as_ref(&self) -> &RawVectorMapper<'a>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a> Debug for IntVectorMapper<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> MemoryMapped<'a> for IntVectorMapper<'a>

Available on non-target_family=wasm only.
Source§

fn new(map: &'a MemoryMap, offset: usize) -> Result<Self>

Returns an immutable memory-mapped structure corresponding to an interval in the file. Read more
Source§

fn map_offset(&self) -> usize

Returns the starting offset in the file.
Source§

fn map_len(&self) -> usize

Returns the length of the interval corresponding to the structure.
Source§

impl<'a> PartialEq for IntVectorMapper<'a>

Source§

fn eq(&self, other: &IntVectorMapper<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Vector for IntVectorMapper<'a>

Available on non-target_family=wasm only.
Source§

type Item = u64

The type of the items in the vector.
Source§

fn len(&self) -> usize

Returns the number of items in the vector.
Source§

fn width(&self) -> usize

Returns the width of of an item in bits.
Source§

fn max_len(&self) -> usize

Returns the maximum length of the vector.
Source§

fn is_empty(&self) -> bool

Returns true if the vector is empty.
Source§

impl<'a> Eq for IntVectorMapper<'a>

Source§

impl<'a> StructuralPartialEq for IntVectorMapper<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for IntVectorMapper<'a>

§

impl<'a> RefUnwindSafe for IntVectorMapper<'a>

§

impl<'a> Send for IntVectorMapper<'a>

§

impl<'a> Sync for IntVectorMapper<'a>

§

impl<'a> Unpin for IntVectorMapper<'a>

§

impl<'a> UnwindSafe for IntVectorMapper<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.