pub struct IndexRegistry<I: Index> { /* private fields */ }Expand description
Generic registry for index entries.
Provides:
- Named lookup with priority-based overrides
- Lazy content loading with caching
- Summary generation for system prompts
§Example
let registry = IndexRegistry::new();
registry.register(skill_index);
// Get metadata (always fast)
let idx = registry.get("commit").unwrap();
// Load full content (lazy, cached)
let content = registry.load_content("commit").await?;
// Generate summary for system prompt
let summary = registry.build_summary();Implementations§
Source§impl<I: Index> IndexRegistry<I>
impl<I: Index> IndexRegistry<I>
Sourcepub fn register(&mut self, index: I)
pub fn register(&mut self, index: I)
Register an index entry.
If an entry with the same name exists, it’s replaced only if the new entry has equal or higher priority.
Sourcepub fn register_all(&mut self, indices: impl IntoIterator<Item = I>)
pub fn register_all(&mut self, indices: impl IntoIterator<Item = I>)
Register multiple index entries.
Sourcepub async fn remove(&mut self, name: &str) -> Option<I>
pub async fn remove(&mut self, name: &str) -> Option<I>
Remove an entry by name.
Also clears the cached content for this entry.
Sourcepub async fn load_content(&self, name: &str) -> Result<String>
pub async fn load_content(&self, name: &str) -> Result<String>
Load content for an index entry with caching.
Returns cached content if available, otherwise loads from source.
Sourcepub async fn invalidate_cache(&self, name: &str)
pub async fn invalidate_cache(&self, name: &str)
Invalidate cached content for an entry.
Sourcepub async fn clear_cache(&self)
pub async fn clear_cache(&self)
Clear all cached content.
Sourcepub fn build_summary(&self) -> String
pub fn build_summary(&self) -> String
Build a summary of all entries for system prompt injection.
Returns a formatted string with one summary line per entry.
Sourcepub fn build_summary_with<F>(&self, formatter: F) -> String
pub fn build_summary_with<F>(&self, formatter: F) -> String
Build a summary with a custom formatter.
Sourcepub fn sorted_by_priority(&self) -> Vec<&I>
pub fn sorted_by_priority(&self) -> Vec<&I>
Get entries sorted by priority (highest first).
Source§impl<I: Index + PathMatched> IndexRegistry<I>
impl<I: Index + PathMatched> IndexRegistry<I>
Sourcepub fn find_matching(&self, path: &Path) -> Vec<&I>
pub fn find_matching(&self, path: &Path) -> Vec<&I>
Sourcepub async fn load_matching(&self, path: &Path) -> Vec<LoadedEntry<I>>
pub async fn load_matching(&self, path: &Path) -> Vec<LoadedEntry<I>>
Load content for all entries matching the given file path.
Returns loaded entries sorted by priority (highest first). Entries that fail to load are skipped.
Sourcepub fn has_matching(&self, path: &Path) -> bool
pub fn has_matching(&self, path: &Path) -> bool
Check if any entry matches the given file path.
Sourcepub fn build_matching_summary(&self, path: &Path) -> String
pub fn build_matching_summary(&self, path: &Path) -> String
Build summary for entries matching a specific path.
Source§impl IndexRegistry<OutputStyle>
impl IndexRegistry<OutputStyle>
pub fn with_builtins() -> Self
cli-integration only.pub async fn load_from_directories( &mut self, working_dir: Option<&Path>, ) -> Result<()>
cli-integration only.Trait Implementations§
Source§impl<I: Index> Clone for IndexRegistry<I>
impl<I: Index> Clone for IndexRegistry<I>
Source§impl<I: Index> Default for IndexRegistry<I>
impl<I: Index> Default for IndexRegistry<I>
Source§impl<I: Index> FromIterator<I> for IndexRegistry<I>
impl<I: Index> FromIterator<I> for IndexRegistry<I>
Source§fn from_iter<T: IntoIterator<Item = I>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = I>>(iter: T) -> Self
Auto Trait Implementations§
impl<I> Freeze for IndexRegistry<I>
impl<I> !RefUnwindSafe for IndexRegistry<I>
impl<I> Send for IndexRegistry<I>
impl<I> Sync for IndexRegistry<I>
impl<I> Unpin for IndexRegistry<I>where
I: Unpin,
impl<I> !UnwindSafe for IndexRegistry<I>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more