Skip to main content

ViewMode

Enum ViewMode 

Source
#[non_exhaustive]
pub enum ViewMode { Virtual, Materialized { top_k: u32, }, }
Expand description

View mode.

use kevy_index::{IndexValue, Leaf, Tree, ViewMode, ViewSpec};
let t = Tree::Leaf(Leaf::new("age", IndexValue::I64(0), IndexValue::I64(99)));
let v = ViewSpec::new("v", t, "age");
assert_eq!(v.mode, ViewMode::Virtual, "views are virtual unless declared otherwise");

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Virtual

Evaluate the tree at query time.

use kevy_index::ViewMode;
assert_eq!(ViewMode::Virtual.name(), "virtual");
§

Materialized

Maintain an incremental result set; top_k = 0 = unbounded.

use kevy_index::ViewMode;
let m = ViewMode::Materialized { top_k: 10 };
assert_eq!(m.name(), "materialized");

Fields

§top_k: u32

Bounded size (0 = keep every member).

use kevy_index::{IndexValue, MaterializedSet, Membership, SortOrder};
// K = 2 keeps K + K/4 = 2 members
let mut top2 = MaterializedSet::new(2, SortOrder::Desc);
for (k, v) in [(b"a", 1), (b"b", 5), (b"c", 3)] {
    top2.apply(k, Membership::Member(Some(IndexValue::I64(v))));
}
assert_eq!(top2.len(), 2, "top_k bounds the members kept");
assert_eq!(top2.page(None, 9)[1], (IndexValue::I64(3), b"c".to_vec()));

Implementations§

Source§

impl ViewMode

Source

pub fn name(&self) -> &'static str

The mode as VIEW.CREATE … MODE and the describe replies spell it.

use kevy_index::ViewMode;
assert_eq!(ViewMode::Virtual.name(), "virtual");
assert_eq!(ViewMode::Materialized { top_k: 5 }.name(), "materialized");

Trait Implementations§

Source§

impl Clone for ViewMode

Source§

fn clone(&self) -> ViewMode

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 Copy for ViewMode

Source§

impl Debug for ViewMode

Source§

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

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

impl Eq for ViewMode

Source§

impl Hash for ViewMode

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ViewMode

Source§

fn eq(&self, other: &ViewMode) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ViewMode

Auto Trait Implementations§

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<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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.