Skip to main content

Language

Trait Language 

Source
pub trait Language: Send + Sync {
    // Required methods
    fn id(&self) -> &'static str;
    fn claims(&self, path: &[u8]) -> bool;

    // Provided method
    fn normalize_line(&self, line: &[u8]) -> Vec<u8> ⓘ { ... }
}
Expand description

A language plugin. Every method has a working generic default, so a new language implements only what it improves on.

Required Methods§

Source

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

Stable identifier, e.g. “generic”, “rust”. Part of the registry fingerprint, so bump-worthy behaviour changes need a new id or version.

Source

fn claims(&self, path: &[u8]) -> bool

Whether this plugin claims the file (typically by extension/basename). The registry’s generic fallback claims everything.

Provided Methods§

Source

fn normalize_line(&self, line: &[u8]) -> Vec<u8> ⓘ

Normalise one line’s content for shape classification: erase what varies between instances of the same edit (identifiers, literals, spacing), keep what distinguishes different edits.

This feeds the shape hash ONLY — never hunk_digest, which is the exact-content persistence anchor.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§