Skip to main content

IndexedValue

Struct IndexedValue 

Source
pub struct IndexedValue<I: Key, V: Value> {
    pub index: I,
    pub value: V,
}
Expand description

A data type used in dup tables that have a subkey. It allows having tables that map from a main key to a subkey (index) to a value (value).

The index/subkey type must have a fixed size declared in its AsDatabaseBytes implementation. Otherwise, the code will panic at compile time.

Fields§

§index: I

The subkey or index.

§value: V

The associated value.

Implementations§

Source§

impl<I: Key, V: Value> IndexedValue<I, V>

Source

pub fn new(index: I, value: V) -> Self

Create a new indexed value.

Trait Implementations§

Source§

impl<I: Key, V: Value> AsDatabaseBytes for IndexedValue<I, V>

Source§

const FIXED_SIZE: Option<usize>

Determines whether the values are of fixed size. This will set the DUP_FIXED_SIZE_VALUES for dup tables flag.
Source§

fn as_key_bytes(&self) -> Cow<'_, [u8]>

Returns the byte representation to be used in key encoding. In the default implementation, this will also be used for the value bytes.
Source§

fn as_value_bytes(&self) -> Cow<'_, [u8]>

Returns the byte representation to be used in value encoding. This is used if the value needs to be sorted differently in a dup table. DUP values use a lexicographic sort order.
Source§

impl<I: Clone + Key, V: Clone + Value> Clone for IndexedValue<I, V>

Source§

fn clone(&self) -> IndexedValue<I, V>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<I: Debug + Key, V: Debug + Value> Debug for IndexedValue<I, V>

Source§

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

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

impl<I: Key, V: Value> DupTableValue for IndexedValue<I, V>

Source§

type SubKey = I

The subkey/index type.

Source§

type Value = V

The value type.

Source§

fn subkey(&self) -> &Self::SubKey

Returns a reference to the subkey.

Source§

fn value(&self) -> &Self::Value

Returns a reference to the value.

Source§

impl<I: Key, V: Value> FromDatabaseBytes for IndexedValue<I, V>

Source§

fn from_key_bytes(bytes: &[u8]) -> Self
where Self: Sized,

Reads the value from the database key bytes. In the default implementation, this will also be used for the value bytes.
Source§

fn from_value_bytes(bytes: &[u8]) -> Self
where Self: Sized,

Reads the value from the database bytes (in value encoding). This is only necessary if the value needs to be sorted differently in a dup table. DUP values use a lexicographic sort order.
Source§

impl<I: PartialEq + Key, V: PartialEq + Value> PartialEq for IndexedValue<I, V>

Source§

fn eq(&self, other: &IndexedValue<I, V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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<I: Eq + Key, V: Eq + Value> Eq for IndexedValue<I, V>

Source§

impl<I: Key, V: Value> StructuralPartialEq for IndexedValue<I, V>

Auto Trait Implementations§

§

impl<I, V> Freeze for IndexedValue<I, V>
where I: Freeze, V: Freeze,

§

impl<I, V> RefUnwindSafe for IndexedValue<I, V>

§

impl<I, V> Send for IndexedValue<I, V>
where I: Send, V: Send,

§

impl<I, V> Sync for IndexedValue<I, V>
where I: Sync, V: Sync,

§

impl<I, V> Unpin for IndexedValue<I, V>
where I: Unpin, V: Unpin,

§

impl<I, V> UnsafeUnpin for IndexedValue<I, V>
where I: UnsafeUnpin, V: UnsafeUnpin,

§

impl<I, V> UnwindSafe for IndexedValue<I, V>
where I: UnwindSafe, V: 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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Value for T
where T: AsDatabaseBytes + FromDatabaseBytes + 'static,