Skip to main content

GrainRenderer

Trait GrainRenderer 

Source
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§

Source

fn grain_type(&self) -> GrainType

Which grain type this renderer handles.

Source

fn render(&self, grain: &DeserializedGrain, policy: &FormatPolicy) -> String

Full render of the grain’s content.

Source

fn context_priority(&self, grain: &DeserializedGrain, hit: &SearchHit) -> f32

Context priority for this grain [0.0, 1.0].

Provided Methods§

Source

fn render_summary( &self, grain: &DeserializedGrain, policy: &FormatPolicy, ) -> String

Compact one-line summary for budget-constrained contexts.

Source

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".

Implementors§