Skip to main content

claw_patch/
lib.rs

1//! Codec-aware diff, patch, invert, commute, and merge behavior.
2//!
3//! Claw VCS uses codecs so different content types can have appropriate merge
4//! semantics. Built-in codecs cover line-oriented text, structural JSON, and
5//! binary replacement.
6//!
7#![deny(missing_docs)]
8
9//! # Example
10//!
11//! ```rust
12//! use claw_patch::text_line::TextLineCodec;
13//! use claw_patch::Codec;
14//!
15//! let codec = TextLineCodec;
16//! let old = b"first\nsecond\nthird\n";
17//! let new = b"first\nchanged\nthird\n";
18//!
19//! let ops = codec.diff(old, new)?;
20//! let applied = codec.apply(old, &ops)?;
21//!
22//! assert_eq!(applied, new);
23//! # Ok::<(), Box<dyn std::error::Error>>(())
24//! ```
25//!
26/// Binary replacement codec.
27pub mod binary;
28/// Codec trait shared by all patch implementations.
29pub mod codec;
30/// Patch codec errors.
31pub mod error;
32/// Structural JSON diff and merge codec.
33pub mod json_tree;
34/// Codec registry and path-to-codec lookup.
35pub mod registry;
36/// Line-oriented text diff and merge codec.
37pub mod text_line;
38
39/// Patch codec behavior.
40pub use codec::Codec;
41/// Patch codec error.
42pub use error::PatchError;
43/// Registry for locating codecs by id or path.
44pub use registry::CodecRegistry;