pub trait Index:
Named
+ Clone
+ Send
+ Sync
+ 'static {
// Required methods
fn source(&self) -> &ContentSource;
fn source_type(&self) -> SourceType;
fn to_summary_line(&self) -> String;
// Provided methods
fn priority(&self) -> i32 { ... }
fn load_content<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn description(&self) -> &str { ... }
}Expand description
Core trait for index entries in the progressive disclosure pattern.
Index entries contain minimal metadata (name, description) that is always available in the system prompt, while full content is loaded on-demand.
§Token Efficiency
By keeping only metadata in context:
- 50 skills × ~20 tokens each = ~1,000 tokens (always loaded)
- vs 50 skills × ~500 tokens each = ~25,000 tokens (if fully loaded)
§Example Implementation
pub struct SkillIndex {
name: String,
description: String,
source: ContentSource,
source_type: SourceType,
}
impl Index for SkillIndex {
fn source(&self) -> &ContentSource { &self.source }
fn source_type(&self) -> SourceType { self.source_type }
fn to_summary_line(&self) -> String {
format!("- {}: {}", self.name, self.description)
}
}Required Methods§
Sourcefn source(&self) -> &ContentSource
fn source(&self) -> &ContentSource
Get the content source for lazy loading.
Sourcefn source_type(&self) -> SourceType
fn source_type(&self) -> SourceType
Get the source type (builtin, user, project, managed).
Sourcefn to_summary_line(&self) -> String
fn to_summary_line(&self) -> String
Generate a summary line for context injection.
This should be a compact representation suitable for system prompts.
Provided Methods§
Sourcefn priority(&self) -> i32
fn priority(&self) -> i32
Get the priority for override ordering.
Higher priority indices override lower priority ones with the same name. Default ordering: Project(20) > User(10) > Builtin(0)
Sourcefn load_content<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn load_content<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Load the full content from the source.
This is the lazy-loading mechanism. Content is fetched only when needed.
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Get a short description for this index entry.
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.