Skip to main content

CrystalIndex

Struct CrystalIndex 

Source
pub struct CrystalIndex { /* private fields */ }
Expand description

In-memory index for fast recall queries.

Implementations§

Source§

impl CrystalIndex

Source

pub fn new() -> Self

Create a new empty index.

Source

pub fn insert(&mut self, meta: TileMeta)

Insert a tile into the index.

Source

pub fn remove(&mut self, id: &TileId) -> Option<TileMeta>

Remove a tile from the index.

Source

pub fn query(&self, constraints: &[&str], limit: usize) -> Vec<TileId>

Query tiles by constraint keywords, returning up to limit matches.

Source

pub fn top_by_valence(&self, limit: usize) -> Vec<TileId>

Get top tiles by valence.

Source

pub fn recent(&self, limit: usize) -> Vec<TileId>

Get most recent tiles.

Source

pub fn get(&self, id: &TileId) -> Option<&TileMeta>

Get a tile’s metadata.

Source

pub fn len(&self) -> usize

Total number of indexed tiles.

Source

pub fn is_empty(&self) -> bool

Is the index empty?

Source

pub fn all_ids(&self) -> Vec<TileId>

Get all tile IDs.

Trait Implementations§

Source§

impl Debug for CrystalIndex

Source§

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

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

impl Default for CrystalIndex

Source§

fn default() -> CrystalIndex

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

impl<'de> Deserialize<'de> for CrystalIndex

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 Serialize for CrystalIndex

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

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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

Source§

type Output = T

Should always be Self
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.