Skip to main content

CompactionStrategy

Trait CompactionStrategy 

Source
pub trait CompactionStrategy: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn should_compact(&self, messages: &[Message], token_estimate: u64) -> bool;
    fn compact(
        &self,
        messages: Vec<Message>,
    ) -> Result<CompactionOutcome, MachiError>;
}
Expand description

Pure compaction strategy.

Required Methods§

Source

fn name(&self) -> &'static str

Stable strategy id (max_messages, token_threshold, …).

Source

fn should_compact(&self, messages: &[Message], token_estimate: u64) -> bool

Whether compaction should run given current size estimates.

Source

fn compact( &self, messages: Vec<Message>, ) -> Result<CompactionOutcome, MachiError>

Produce a compacted message list.

§Errors

Returns typed compaction failures (should not panic on normal input).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§