pub struct ActiveWindow { /* private fields */ }Expand description
Manages the short-term active window of conversation messages.
When messages are pushed and the window exceeds policy limits, the
window is trimmed. Evicted messages are either demoted to long-term
storage (via DemotionHook) or compacted into a summary
(via Compactor) — never silently discarded.
Implementations§
Source§impl ActiveWindow
impl ActiveWindow
Sourcepub fn new(policy: MemoryPolicy) -> Self
pub fn new(policy: MemoryPolicy) -> Self
Creates a new active window with the given policy.
Sourcepub fn with_demotion_hook(self, hook: Box<dyn DemotionHook>) -> Self
pub fn with_demotion_hook(self, hook: Box<dyn DemotionHook>) -> Self
Sets the demotion hook.
Sourcepub fn with_compactor(self, compactor: Box<dyn Compactor>) -> Self
pub fn with_compactor(self, compactor: Box<dyn Compactor>) -> Self
Sets the compactor.
Sourcepub fn push(&mut self, msg: Message) -> Vec<MemoryEvent>
pub fn push(&mut self, msg: Message) -> Vec<MemoryEvent>
Pushes a message into the active window.
Returns memory events if trimming was triggered.
Sourcepub fn trim_if_needed(&mut self) -> Vec<MemoryEvent>
pub fn trim_if_needed(&mut self) -> Vec<MemoryEvent>
Trims the window if it exceeds policy limits.
Evicted messages are processed through the demotion hook and/or compactor, never silently dropped.
Auto Trait Implementations§
impl !RefUnwindSafe for ActiveWindow
impl !UnwindSafe for ActiveWindow
impl Freeze for ActiveWindow
impl Send for ActiveWindow
impl Sync for ActiveWindow
impl Unpin for ActiveWindow
impl UnsafeUnpin for ActiveWindow
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