pub struct PersistentContext { /* private fields */ }Expand description
Aggregates named context sections and renders them into a single string.
Sections are sorted by priority (ascending) before rendering. Use this to
build structured system prompts from multiple independent sources.
§Example
use neuron_context::{PersistentContext, ContextSection};
let mut ctx = PersistentContext::new();
ctx.add_section(ContextSection { label: "Role".into(), content: "You are helpful.".into(), priority: 0 });
ctx.add_section(ContextSection { label: "Rules".into(), content: "Be concise.".into(), priority: 10 });
let rendered = ctx.render();
assert!(rendered.contains("Role"));
assert!(rendered.contains("Rules"));Implementations§
Source§impl PersistentContext
impl PersistentContext
Sourcepub fn add_section(&mut self, section: ContextSection)
pub fn add_section(&mut self, section: ContextSection)
Adds a section to this context.
Trait Implementations§
Source§impl Debug for PersistentContext
impl Debug for PersistentContext
Source§impl Default for PersistentContext
impl Default for PersistentContext
Source§fn default() -> PersistentContext
fn default() -> PersistentContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for PersistentContext
impl RefUnwindSafe for PersistentContext
impl Send for PersistentContext
impl Sync for PersistentContext
impl Unpin for PersistentContext
impl UnsafeUnpin for PersistentContext
impl UnwindSafe for PersistentContext
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
Mutably borrows from an owned value. Read more