Skip to main content

Compressor

Trait Compressor 

Source
pub trait Compressor: Send + Sync {
    // Required methods
    fn matches(&self, command: &str) -> bool;
    fn compress(&self, command: &str, output: &str) -> CompressionResult;

    // Provided methods
    fn specificity(&self) -> Specificity { ... }
    fn matches_output(&self, _output: &str) -> bool { ... }
    fn compress_output_match(&self, output: &str) -> CompressionResult { ... }
}
Expand description

A Compressor knows how to reduce one specific command’s output to fewer tokens while preserving the information the agent needs.

Required Methods§

Source

fn matches(&self, command: &str) -> bool

Returns true if this compressor handles the given command head + args. Called after generic detection (ANSI strip, dedup) so this is per-command logic only.

Source

fn compress(&self, command: &str, output: &str) -> CompressionResult

Compress the output. Original is left untouched if compression fails.

Provided Methods§

Source

fn specificity(&self) -> Specificity

Source

fn matches_output(&self, _output: &str) -> bool

Returns true when this compressor recognizes output produced by its inner tool even if the command head was a wrapper (npm test, make test, ./scripts/check.sh, etc.). Wrapper compressors should not override this; they remain command-only.

Source

fn compress_output_match(&self, output: &str) -> CompressionResult

Compress output after an output-shape match. Compressors that branch by subcommand override this to jump directly to the matched branch.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§