SearchableEntity

Trait SearchableEntity 

Source
pub trait SearchableEntity<SearchKey: KeyType>: Entity {
    // Required methods
    fn find_all_matching<'life0, 'life1, 'async_trait>(
        conn: &'life0 mut Self::ConnectionType,
        search_key: &'life1 SearchKey,
    ) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Vec<Self>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn matches(&self, search_key: &SearchKey) -> bool;
}
Expand description

Entities implementing SearchableEntity have a distinct search key which can produce multiple items.

Effectively, this is a way at the type-system level to implement WHERE-clause searching.

This trait can potentially be implemented multiple times per entity, in case there are a variety of interesting searches.

While the trait design does not require it, implementations should take advantage of database features such as indices to ensure that searching by a search key is efficient.

Required Methods§

Source

fn find_all_matching<'life0, 'life1, 'async_trait>( conn: &'life0 mut Self::ConnectionType, search_key: &'life1 SearchKey, ) -> Pin<Box<dyn Future<Output = CryptoKeystoreResult<Vec<Self>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Find all entities matching the search key.

The specific meaning of “matching” the search key will depend on the entity in question, but generally the search key will have one or more fields which effectively act as a WHERE-clause for the search.

Source

fn matches(&self, search_key: &SearchKey) -> bool

true when this entity instance matches the search key.

The specific meaning of “matching” the search key will depend on the entity in question, but generally the search key will have one or more fields which must equal some fields on the entity.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§