pub trait FormatPackage: Send + Sync {
// Required methods
fn id(&self) -> PackageId;
fn detect(&self, path: &str, bytes: &[u8]) -> Option<Confidence>;
fn project(&self, bytes: &[u8]) -> Result<Projection, PackageError>;
// Provided method
fn diff(
&self,
_before: &[u8],
_after: &[u8],
) -> Option<Result<Vec<Delta>, PackageError>> { ... }
}Expand description
One format’s support, shipped as its own versioned unit: the ecosystem’s public ABI (ADR-0003).
A package never gates a diff — when it is absent or fails, fidelity drops
to the text or binary rung instead. Determinism is contract: the same
bytes under the same package version must produce the same projection
and the same diff. Send + Sync is part of the ABI: a workspace crosses
threads (a watcher, a server), so its packages must too.
Required Methods§
Sourcefn detect(&self, path: &str, bytes: &[u8]) -> Option<Confidence>
fn detect(&self, path: &str, bytes: &[u8]) -> Option<Confidence>
How confidently this package claims the document at path with
these bytes; None when it does not handle the document.
Sourcefn project(&self, bytes: &[u8]) -> Result<Projection, PackageError>
fn project(&self, bytes: &[u8]) -> Result<Projection, PackageError>
Render the document to its text projection.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".