pub trait GrainRenderer: Send + Sync {
// Required methods
fn grain_type(&self) -> GrainType;
fn render(&self, grain: &DeserializedGrain, policy: &FormatPolicy) -> String;
fn context_priority(
&self,
grain: &DeserializedGrain,
hit: &SearchHit,
) -> f32;
// Provided methods
fn render_summary(
&self,
grain: &DeserializedGrain,
policy: &FormatPolicy,
) -> String { ... }
fn token_estimate(
&self,
grain: &DeserializedGrain,
policy: &FormatPolicy,
) -> usize { ... }
}Expand description
Renders a single grain type into formatted context strings.
Object-safe: stored in RendererRegistry keyed by GrainType.
Required Methods§
Sourcefn grain_type(&self) -> GrainType
fn grain_type(&self) -> GrainType
Which grain type this renderer handles.
Sourcefn render(&self, grain: &DeserializedGrain, policy: &FormatPolicy) -> String
fn render(&self, grain: &DeserializedGrain, policy: &FormatPolicy) -> String
Full render of the grain’s content.
Sourcefn context_priority(&self, grain: &DeserializedGrain, hit: &SearchHit) -> f32
fn context_priority(&self, grain: &DeserializedGrain, hit: &SearchHit) -> f32
Context priority for this grain [0.0, 1.0].
Provided Methods§
Sourcefn render_summary(
&self,
grain: &DeserializedGrain,
policy: &FormatPolicy,
) -> String
fn render_summary( &self, grain: &DeserializedGrain, policy: &FormatPolicy, ) -> String
Compact one-line summary for budget-constrained contexts.
Sourcefn token_estimate(
&self,
grain: &DeserializedGrain,
policy: &FormatPolicy,
) -> usize
fn token_estimate( &self, grain: &DeserializedGrain, policy: &FormatPolicy, ) -> usize
Estimated token count for the full render (~4 chars per token).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".