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§
Sourcefn should_compact(&self, messages: &[Message], token_estimate: u64) -> bool
fn should_compact(&self, messages: &[Message], token_estimate: u64) -> bool
Whether compaction should run given current size estimates.
Sourcefn compact(
&self,
messages: Vec<Message>,
) -> Result<CompactionOutcome, MachiError>
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".