use {
crate::{
core::{Ident, SymbolPath, Value, Visibility},
partitions::{file::FileSymbols, records::SymbolEntry, symbols::Symbols},
},
laburnum::database::{
HasPartition, RecordRef,
query::QueryClient,
storage::Partitions,
},
};
pub trait SymboliqueReadExt<P: Partitions> {
fn file_symbol_at_path<V, I, Path, S>(
&self,
sort_key: &Path,
) -> Option<SymbolEntry<V, I, Path, S>>
where
V: Value<I>,
I: Ident,
Path: SymbolPath,
S: Visibility,
P::Stores: HasPartition<FileSymbols<V, I, Path, S>>;
fn file_symbols_with_prefix<V, I, Path, S>(
&self,
prefix: &Path,
) -> Vec<(Path, SymbolEntry<V, I, Path, S>)>
where
V: Value<I>,
I: Ident,
Path: SymbolPath,
S: Visibility,
P::Stores: HasPartition<FileSymbols<V, I, Path, S>>;
fn resolve_file_symbol<V, I, Path, S>(
&self,
entry: &SymbolEntry<V, I, Path, S>,
) -> Option<RecordRef<'_, Symbols<V, I, Path, S>>>
where
V: Value<I> + 'static,
I: Ident,
Path: SymbolPath + 'static,
S: Visibility,
P::Stores: HasPartition<Symbols<V, I, Path, S>>;
}
impl<P: Partitions> SymboliqueReadExt<P> for QueryClient<P> {
fn file_symbol_at_path<V, I, Path, S>(
&self,
sort_key: &Path,
) -> Option<SymbolEntry<V, I, Path, S>>
where
V: Value<I>,
I: Ident,
Path: SymbolPath,
S: Visibility,
P::Stores: HasPartition<FileSymbols<V, I, Path, S>>,
{
self.index_get::<FileSymbols<V, I, Path, S>>(sort_key)
}
fn file_symbols_with_prefix<V, I, Path, S>(
&self,
prefix: &Path,
) -> Vec<(Path, SymbolEntry<V, I, Path, S>)>
where
V: Value<I>,
I: Ident,
Path: SymbolPath,
S: Visibility,
P::Stores: HasPartition<FileSymbols<V, I, Path, S>>,
{
self.index_range::<FileSymbols<V, I, Path, S>>(prefix)
}
fn resolve_file_symbol<V, I, Path, S>(
&self,
entry: &SymbolEntry<V, I, Path, S>,
) -> Option<RecordRef<'_, Symbols<V, I, Path, S>>>
where
V: Value<I> + 'static,
I: Ident,
Path: SymbolPath + 'static,
S: Visibility,
P::Stores: HasPartition<Symbols<V, I, Path, S>>,
{
self.get::<Symbols<V, I, Path, S>>(entry.symbol.content_hash())
}
}