RenderContext

Struct RenderContext 

Source
pub struct RenderContext {
    pub task_type: Option<String>,
    pub user_states: Vec<String>,
    pub task_health: Option<TaskHealth>,
}
Expand description

Runtime context for prompt rendering

Encapsulates the current state that determines which knowledge fragments should be included and how they should be prioritized.

§Examples

use llm_toolkit_expertise::render::RenderContext;
use llm_toolkit_expertise::context::TaskHealth;

let context = RenderContext::new()
    .with_task_type("security-review")
    .with_user_state("beginner")
    .with_task_health(TaskHealth::AtRisk);

Fields§

§task_type: Option<String>

Current task type (e.g., “security-review”, “code-review”, “debug”)

§user_states: Vec<String>

User states (e.g., “beginner”, “expert”, “confused”)

§task_health: Option<TaskHealth>

Current task health status

Implementations§

Source§

impl RenderContext

Source

pub fn new() -> Self

Create a new empty render context

Source

pub fn with_task_type(self, task_type: impl Into<String>) -> Self

Set the task type

§Examples
use llm_toolkit_expertise::render::RenderContext;

let context = RenderContext::new()
    .with_task_type("security-review");
Source

pub fn with_user_state(self, state: impl Into<String>) -> Self

Add a user state

§Examples
use llm_toolkit_expertise::render::RenderContext;

let context = RenderContext::new()
    .with_user_state("beginner")
    .with_user_state("confused");
Source

pub fn with_task_health(self, health: TaskHealth) -> Self

Set the task health

§Examples
use llm_toolkit_expertise::render::RenderContext;
use llm_toolkit_expertise::context::TaskHealth;

let context = RenderContext::new()
    .with_task_health(TaskHealth::AtRisk);
Source

pub fn matches(&self, profile: &ContextProfile) -> bool

Check if this context matches a ContextProfile

A context matches a profile if:

  • Profile is Always → always matches
  • Profile is Conditional:
    • If task_types is non-empty, current task_type must be in the list
    • If user_states is non-empty, at least one user_state must match
    • If task_health is set, current health must match
§Examples
use llm_toolkit_expertise::render::RenderContext;
use llm_toolkit_expertise::context::{ContextProfile, TaskHealth};

let context = RenderContext::new()
    .with_task_type("security-review")
    .with_task_health(TaskHealth::AtRisk);

let profile = ContextProfile::Conditional {
    task_types: vec!["security-review".to_string()],
    user_states: vec![],
    task_health: Some(TaskHealth::AtRisk),
};

assert!(context.matches(&profile));
Source

pub fn to_context_matcher(&self) -> ContextMatcher

Convert to legacy ContextMatcher for backward compatibility

Note: ContextMatcher only supports a single user_state, so the first user_state from the Vec will be used.

Trait Implementations§

Source§

impl Clone for RenderContext

Source§

fn clone(&self) -> RenderContext

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RenderContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RenderContext

Source§

fn default() -> RenderContext

Returns the “default value” for a type. Read more
Source§

impl From<ContextMatcher> for RenderContext

Convert from legacy ContextMatcher

Source§

fn from(matcher: ContextMatcher) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for RenderContext

Source§

fn eq(&self, other: &RenderContext) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for RenderContext

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.