Skip to main content

SutureDriver

Trait SutureDriver 

Source
pub trait SutureDriver: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn supported_extensions(&self) -> &[&str];
    fn diff(
        &self,
        base_content: Option<&str>,
        new_content: &str,
    ) -> Result<Vec<SemanticChange>, DriverError>;
    fn format_diff(
        &self,
        base_content: Option<&str>,
        new_content: &str,
    ) -> Result<String, DriverError>;

    // Provided method
    fn merge(
        &self,
        _base: &str,
        _ours: &str,
        _theirs: &str,
    ) -> Result<Option<String>, DriverError> { ... }
}
Expand description

Format-specific driver for translating between file formats and Suture patches.

Implementations must be Send + Sync for concurrent use across threads. A driver understands the semantics of a file format — it knows that changing a key in a JSON object is a different operation than appending to an array.

Required Methods§

Source

fn name(&self) -> &str

Human-readable driver name (e.g., “JSON”, “OpenTimelineIO”, “CSV”).

Source

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

File extensions this driver handles (e.g., [".json", ".jsonl"]).

Source

fn diff( &self, base_content: Option<&str>, new_content: &str, ) -> Result<Vec<SemanticChange>, DriverError>

Parse a file and produce a semantic diff between it and an optional base.

If base_content is None, this is a new file — produce creation patches. If base_content is Some, produce patches representing the differences.

Each returned SemanticChange describes a meaningful semantic operation (e.g., “key users.2.email changed from old@example.com to new@example.com”).

Source

fn format_diff( &self, base_content: Option<&str>, new_content: &str, ) -> Result<String, DriverError>

Produce a human-readable diff string between two versions of a file.

This is used by suture diff when a driver is available for the file type. The output should be more meaningful than raw line diffs — showing semantic operations like key changes, array insertions, etc.

Provided Methods§

Source

fn merge( &self, _base: &str, _ours: &str, _theirs: &str, ) -> Result<Option<String>, DriverError>

Perform a semantic three-way merge.

Given base, ours, and theirs content, produce a merged result. Returns None if the merge cannot be resolved automatically (conflict). Returns Some(merged_content) if the merge is clean.

Implementors§