use {
crate::{
core::{Ident, SymbolPath, Value},
partitions::{linked::LinkedSymbols, records::SymbolEntry, symbols::Symbols},
},
laburnum::database::{
HasPartition, RecordRef,
query::QueryClient,
storage::Partitions,
},
};
pub trait LinkedSymboliqueReadExt<P: Partitions> {
fn linked_symbol_at_path<V, I, Path>(
&self,
sort_key: &str,
) -> Option<SymbolEntry<V, I, Path>>
where
V: Value<I>,
I: Ident,
Path: SymbolPath,
P::Stores: HasPartition<LinkedSymbols<V, I, Path>>;
fn linked_symbols_with_prefix<V, I, Path>(
&self,
prefix: &str,
) -> Vec<(String, SymbolEntry<V, I, Path>)>
where
V: Value<I>,
I: Ident,
Path: SymbolPath,
P::Stores: HasPartition<LinkedSymbols<V, I, Path>>;
fn resolve_linked_symbol<V, I, Path>(
&self,
entry: &SymbolEntry<V, I, Path>,
) -> Option<RecordRef<'_, Symbols<V, I, Path>>>
where
V: Value<I> + 'static,
I: Ident,
Path: SymbolPath + 'static,
P::Stores: HasPartition<Symbols<V, I, Path>>;
}
impl<P: Partitions> LinkedSymboliqueReadExt<P> for QueryClient<P> {
fn linked_symbol_at_path<V, I, Path>(
&self,
sort_key: &str,
) -> Option<SymbolEntry<V, I, Path>>
where
V: Value<I>,
I: Ident,
Path: SymbolPath,
P::Stores: HasPartition<LinkedSymbols<V, I, Path>>,
{
self.index_get::<LinkedSymbols<V, I, Path>>(sort_key)
}
fn linked_symbols_with_prefix<V, I, Path>(
&self,
prefix: &str,
) -> Vec<(String, SymbolEntry<V, I, Path>)>
where
V: Value<I>,
I: Ident,
Path: SymbolPath,
P::Stores: HasPartition<LinkedSymbols<V, I, Path>>,
{
self.index_range::<LinkedSymbols<V, I, Path>>(prefix)
}
fn resolve_linked_symbol<V, I, Path>(
&self,
entry: &SymbolEntry<V, I, Path>,
) -> Option<RecordRef<'_, Symbols<V, I, Path>>>
where
V: Value<I> + 'static,
I: Ident,
Path: SymbolPath + 'static,
P::Stores: HasPartition<Symbols<V, I, Path>>,
{
self.get::<Symbols<V, I, Path>>(entry.symbol.content_hash())
}
}