Vecx

Struct Vecx 

Source
pub struct Vecx<T> { /* private fields */ }
Expand description

A disk-based, Vec-like data structure with typed values.

Vecx stores a sequence of values on disk, encoding them for persistence.

Implementations§

Source§

impl<T: ValueEnDe> Vecx<T>

Source

pub unsafe fn shadow(&self) -> Self

Creates a “shadow” copy of the Vecx instance.

§Safety

This API breaks Rust’s semantic safety guarantees. Use only in a race-free environment.

Source

pub unsafe fn from_bytes(s: impl AsRef<[u8]>) -> Self

Creates a Vecx from a byte slice.

§Safety

This function is unsafe and assumes the byte slice is a valid representation.

Source

pub fn as_bytes(&self) -> &[u8]

Returns the byte representation of the Vecx.

Source

pub fn new() -> Self

Creates a new, empty Vecx.

Source

pub fn get(&self, idx: usize) -> Option<T>

Retrieves a value at a specific index.

Source

pub fn get_mut(&mut self, idx: usize) -> Option<ValueMut<'_, T>>

Retrieves a mutable reference to a value at a specific index.

Source

pub fn last(&self) -> Option<T>

Retrieves the last value in the vector.

Source

pub fn len(&self) -> usize

Returns the number of values in the vector.

Source

pub fn is_empty(&self) -> bool

Checks if the vector is empty.

Source

pub fn push(&mut self, v: &T)

Appends a value to the end of the vector.

Source

pub fn insert(&mut self, idx: usize, v: &T)

Inserts a value at a specific index.

§Panics

Panics if idx is out of bounds.

Source

pub fn pop(&mut self) -> Option<T>

Removes and returns the last value in the vector.

Source

pub fn remove(&mut self, idx: usize) -> T

Removes and returns the value at a specific index.

§Panics

Panics if idx is out of bounds.

Source

pub fn swap_remove(&mut self, idx: usize) -> T

Removes a value at a specific index and returns it, replacing it with the last value.

§Panics

Panics if idx is out of bounds.

Source

pub fn update(&mut self, idx: usize, v: &T) -> Option<T>

Updates the value at a specific index.

§Panics

Panics if idx is out of bounds.

Source

pub fn iter(&self) -> VecxIter<'_, T>

Returns an iterator over the vector’s values.

Source

pub fn iter_mut(&mut self) -> VecxIterMut<'_, T>

Returns a mutable iterator over the vector’s values.

Source

pub fn clear(&mut self)

Clears the vector, removing all values.

Source

pub fn is_the_same_instance(&self, other_hdr: &Self) -> bool

Checks if this Vecx instance is the same as another.

Trait Implementations§

Source§

impl<T> Clone for Vecx<T>

Source§

fn clone(&self) -> Self

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<T: Debug> Debug for Vecx<T>

Source§

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

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

impl<T: ValueEnDe> Default for Vecx<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, T> Deserialize<'de> for Vecx<T>

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: PartialEq> PartialEq for Vecx<T>

Source§

fn eq(&self, other: &Vecx<T>) -> 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<T> Serialize for Vecx<T>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: Eq> Eq for Vecx<T>

Source§

impl<T> StructuralPartialEq for Vecx<T>

Auto Trait Implementations§

§

impl<T> !Freeze for Vecx<T>

§

impl<T> RefUnwindSafe for Vecx<T>
where T: RefUnwindSafe,

§

impl<T> Send for Vecx<T>
where T: Send,

§

impl<T> Sync for Vecx<T>
where T: Sync,

§

impl<T> Unpin for Vecx<T>
where T: Unpin,

§

impl<T> UnwindSafe for Vecx<T>
where 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> KeyDe for T

Source§

fn decode_key(bytes: &[u8]) -> Result<T, Box<dyn RucError>>

Decodes a key from a byte slice.
Source§

impl<T> KeyEn for T
where T: Serialize,

Source§

fn try_encode_key(&self) -> Result<Vec<u8>, Box<dyn RucError>>

Tries to encode the key into a byte vector.
Source§

fn encode_key(&self) -> RawBytes

Encodes the key into a byte vector, panicking on failure.
Source§

impl<T> KeyEnDe for T
where T: KeyEn + KeyDe,

Source§

fn try_encode(&self) -> Result<Vec<u8>, Box<dyn RucError>>

Tries to encode the key into a byte vector.
Source§

fn encode(&self) -> Vec<u8>

Encodes the key into a byte vector, panicking on failure.
Source§

fn decode(bytes: &[u8]) -> Result<T, Box<dyn RucError>>

Decodes a key from a byte slice.
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<T> ValueDe for T

Source§

fn decode_value(bytes: &[u8]) -> Result<T, Box<dyn RucError>>

Decodes a value from a byte slice.
Source§

impl<T> ValueEn for T
where T: Serialize,

Source§

fn try_encode_value(&self) -> Result<Vec<u8>, Box<dyn RucError>>

Tries to encode the value into a byte vector.
Source§

fn encode_value(&self) -> RawBytes

Encodes the value into a byte vector, panicking on failure.
Source§

impl<T> ValueEnDe for T
where T: ValueEn + ValueDe,

Source§

fn try_encode(&self) -> Result<Vec<u8>, Box<dyn RucError>>

Tries to encode the value into a byte vector.
Source§

fn encode(&self) -> Vec<u8>

Encodes the value into a byte vector, panicking on failure.
Source§

fn decode(bytes: &[u8]) -> Result<T, Box<dyn RucError>>

Decodes a value from a byte slice.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,