Skip to main content

CompressionPattern

Trait CompressionPattern 

Source
pub trait CompressionPattern: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn matches(&self, command: &str) -> bool;
    fn compress(&self, command: &str, output: &str) -> Option<String>;
    fn prefixes(&self) -> &[&str];

    // Provided method
    fn version(&self) -> u32 { ... }
}
Expand description

Plugin-ready trait for shell output compression patterns.

Each pattern matches a specific CLI tool (or family of tools) and compresses its output into a token-efficient representation.

Existing patterns implement this via the blanket compress(cmd, output) functions. Future plugins will register implementations dynamically.

Required Methods§

Source

fn name(&self) -> &str

Human-readable name for this pattern (e.g. “cargo”, “git”, “docker”).

Source

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

Returns true if this pattern can handle the given command. Called during dispatch to find the appropriate pattern.

Source

fn compress(&self, command: &str, output: &str) -> Option<String>

Compress the shell output for the matched command. Returns None if the pattern cannot produce a shorter result.

Source

fn prefixes(&self) -> &[&str]

Command prefixes this pattern handles (for documentation/discovery).

Provided Methods§

Source

fn version(&self) -> u32

Version of this pattern’s output format. Bump when the compressed output structure changes to maintain determinism guarantees.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§