use {
super::records::SymbolEntry,
crate::core::{Ident, Symbol, SymbolPath, SymbolSortKey, Value},
laburnum::{
ContentHash, Ident as LaburnumIdent,
database::{Partition, PartitionKey},
record::{Record, hash_record},
},
std::{hash::Hash, marker::PhantomData},
};
#[derive(Hash)]
pub struct FileSymbols<V, I, P>(PhantomData<(V, I, P)>);
impl<V, I, P> Default for FileSymbols<V, I, P> {
fn default() -> Self {
Self(PhantomData)
}
}
impl<V, I, P> Clone for FileSymbols<V, I, P> {
fn clone(&self) -> Self {
*self
}
}
impl<V, I, P> Copy for FileSymbols<V, I, P> {}
impl<V, I, P> std::fmt::Debug for FileSymbols<V, I, P> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("FileSymbols").finish()
}
}
impl<V, I, P> PartitionKey for FileSymbols<V, I, P>
where
V: Value<I>,
I: Ident,
P: SymbolPath,
{
const KEY: LaburnumIdent = LaburnumIdent::new("symbolique::file_symbols");
}
impl<V, I, P> Partition for FileSymbols<V, I, P>
where
V: Value<I>,
I: Ident,
P: SymbolPath,
{
type Record = (); type IndexEntry = SymbolEntry<V, I, P>;
type SortKey = SymbolSortKey;
}
#[derive(Hash)]
pub struct FileSymbolIndex<V, I, P>(PhantomData<(V, I, P)>);
impl<V, I, P> Default for FileSymbolIndex<V, I, P> {
fn default() -> Self {
Self(PhantomData)
}
}
impl<V, I, P> Clone for FileSymbolIndex<V, I, P> {
fn clone(&self) -> Self {
*self
}
}
impl<V, I, P> Copy for FileSymbolIndex<V, I, P> {}
impl<V, I, P> std::fmt::Debug for FileSymbolIndex<V, I, P> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("FileSymbolIndex").finish()
}
}
impl<V, I, P> PartitionKey for FileSymbolIndex<V, I, P>
where
V: Value<I>,
I: Ident,
P: SymbolPath,
{
const KEY: LaburnumIdent =
LaburnumIdent::new("symbolique::file_symbol_index");
}
impl<V, I, P> Partition for FileSymbolIndex<V, I, P>
where
V: Value<I>,
I: Ident,
P: SymbolPath,
{
type Record = (); type IndexEntry = SymbolEntry<V, I, P>;
type SortKey = SymbolSortKey;
}
impl<V, I, P> Record for Symbol<V, I, P>
where
V: Value<I>,
I: Ident,
P: SymbolPath,
{
fn content_hash(&self) -> ContentHash {
hash_record(self)
}
}