Enum StoredVec

Source
pub enum StoredVec<I, T> {
    Raw(RawVec<I, T>),
    Compressed(CompressedVec<I, T>),
}

Variants§

§

Raw(RawVec<I, T>)

§

Compressed(CompressedVec<I, T>)

Implementations§

Source§

impl<I, T> StoredVec<I, T>
where I: StoredIndex, T: StoredType,

Source

pub fn forced_import( path: &Path, value_name: &str, version: Version, format: Format, ) -> Result<Self>

Examples found in repository?
examples/main.rs (line 14)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7    let _ = fs::remove_dir_all("./vec");
8
9    let version = Version::ZERO;
10    let format = Format::Compressed;
11
12    {
13        let mut vec: StoredVec<usize, u32> =
14            StoredVec::forced_import(Path::new("."), "vec", version, format)?;
15
16        (0..21_u32).for_each(|v| {
17            vec.push(v);
18        });
19
20        let mut iter = vec.into_iter();
21        dbg!(iter.get(0));
22        dbg!(iter.get(20));
23        dbg!(iter.get(21));
24
25        vec.flush()?;
26    }
27
28    {
29        let mut vec: StoredVec<usize, u32> =
30            StoredVec::forced_import(Path::new("."), "vec", version, format)?;
31        let mut iter = vec.into_iter();
32
33        dbg!(iter.get(0));
34        dbg!(iter.get(0));
35        dbg!(iter.get(1));
36        dbg!(iter.get(2));
37        dbg!(iter.get(20));
38        dbg!(iter.get(20));
39        dbg!(iter.get(0));
40
41        vec.push(21);
42        vec.push(22);
43
44        let mut iter = vec.into_iter();
45
46        dbg!(iter.get(20));
47        dbg!(iter.get(21));
48        dbg!(iter.get(22));
49        dbg!(iter.get(23));
50
51        vec.flush()?;
52    }
53
54    {
55        let mut vec: StoredVec<usize, u32> =
56            StoredVec::forced_import(Path::new("."), "vec", version, format)?;
57        let mut iter = vec.into_iter();
58
59        dbg!(iter.get(0));
60        dbg!(iter.get(20));
61        dbg!(iter.get(21));
62        dbg!(iter.get(22));
63
64        vec.truncate_if_needed(14)?;
65
66        let mut iter = vec.into_iter();
67
68        iter.get(0);
69        iter.get(5);
70        dbg!(iter.get(20));
71
72        dbg!(vec.collect_signed_range(Some(-5), None)?);
73
74        vec.push(vec.len() as u32);
75        dbg!(VecIterator::last(vec.into_iter()));
76
77        dbg!(vec.into_iter().collect::<Vec<_>>());
78    }
79
80    Ok(())
81}

Trait Implementations§

Source§

impl<I, T> AnyCollectableVec for StoredVec<I, T>
where I: StoredIndex, T: StoredType,

Source§

impl<I, T> AnyIterableVec<I, T> for StoredVec<I, T>
where I: StoredIndex, T: StoredType,

Source§

fn boxed_iter<'a>(&'a self) -> BoxedVecIterator<'a, I, T>
where T: 'a,

Source§

fn iter<'a>(&'a self) -> BoxedVecIterator<'a, I, T>
where I: StoredIndex, T: StoredType + 'a,

Source§

fn iter_at<'a>(&'a self, i: I) -> BoxedVecIterator<'a, I, T>
where I: StoredIndex, T: StoredType + 'a,

Source§

fn iter_at_<'a>(&'a self, i: usize) -> BoxedVecIterator<'a, I, T>
where I: StoredIndex, T: StoredType + 'a,

Source§

impl<I, T> AnyVec for StoredVec<I, T>
where I: StoredIndex, T: StoredType,

Source§

impl<I: Clone, T: Clone> Clone for StoredVec<I, T>

Source§

fn clone(&self) -> StoredVec<I, T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<I: Debug, T: Debug> Debug for StoredVec<I, T>

Source§

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

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

impl<I, T> GenericStoredVec<I, T> for StoredVec<I, T>
where I: StoredIndex, T: StoredType,

Source§

fn read_(&self, index: usize, guard: &Mmap) -> Result<Option<T>>

Source§

fn mmap(&self) -> &ArcSwap<Mmap>

Source§

fn stored_len(&self) -> usize

Source§

fn pushed(&self) -> &[T]

Source§

fn mut_pushed(&mut self) -> &mut Vec<T>

Source§

fn path(&self) -> &Path

Source§

fn flush(&mut self) -> Result<()>

Source§

fn truncate_if_needed(&mut self, index: I) -> Result<()>

Source§

const SIZE_OF_T: usize = _

Source§

fn read(&self, index: I, mmap: &Mmap) -> Result<Option<T>>

Source§

fn get_or_read(&self, index: I, mmap: &Mmap) -> Result<Option<Value<'_, T>>>

Source§

fn get_or_read_( &self, index: usize, mmap: &Mmap, ) -> Result<Option<Value<'_, T>>>

Source§

fn len_(&self) -> usize

Source§

fn pushed_len(&self) -> usize

Source§

fn push(&mut self, value: T)

Source§

fn open_file(&self) -> Result<File>

Source§

fn open_file_(path: &Path) -> Result<File>

Source§

fn file_set_len(&mut self, len: u64) -> Result<()>

Source§

fn file_set_len_(file: &mut File, len: u64) -> Result<()>

Source§

fn file_write_all(&mut self, buf: &[u8]) -> Result<()>

Source§

fn file_truncate_and_write_all(&mut self, len: u64, buf: &[u8]) -> Result<()>

Source§

fn reset(&mut self) -> Result<()>

Source§

fn new_mmap(file: File) -> Result<Arc<Mmap>>

Source§

fn update_mmap(&mut self, file: File) -> Result<()>

Source§

fn is_pushed_empty(&self) -> bool

Source§

fn has(&self, index: I) -> Result<bool>

Source§

fn has_(&self, index: usize) -> bool

Source§

fn path_vec(&self) -> PathBuf

Source§

fn path_vec_(path: &Path) -> PathBuf

Source§

fn path_version_(path: &Path) -> PathBuf

Source§

fn path_compressed_(path: &Path) -> PathBuf

Source§

fn name_(&self) -> String

Source§

fn modified_time_(&self) -> Result<Duration>

Source§

impl<'a, I, T> IntoIterator for &'a StoredVec<I, T>
where I: StoredIndex, T: StoredType,

Source§

type Item = (I, Value<'a, T>)

The type of the elements being iterated over.
Source§

type IntoIter = StoredVecIterator<'a, I, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<I, T> Freeze for StoredVec<I, T>

§

impl<I, T> RefUnwindSafe for StoredVec<I, T>

§

impl<I, T> Send for StoredVec<I, T>
where I: Send, T: Send,

§

impl<I, T> Sync for StoredVec<I, T>
where I: Sync, T: Sync,

§

impl<I, T> Unpin for StoredVec<I, T>
where I: Unpin, T: Unpin,

§

impl<I, T> UnwindSafe for StoredVec<I, T>
where I: UnwindSafe, T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<I, T, U> CloneableAnyIterableVec<I, T> for U
where U: 'static + AnyIterableVec<I, T> + Clone,

Source§

impl<I, T, V> CollectableVec<I, T> for V
where V: AnyVec + AnyIterableVec<I, T> + Clone, I: StoredIndex, T: StoredType,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V