Crate copia

Crate copia 

Source
Expand description

§Copia

Pure Rust rsync-style synchronization for Sovereign AI.

Copia implements the rsync delta-transfer algorithm in 100% safe Rust, providing memory-safe, auditable, high-performance file synchronization.

§Features

  • Rolling Checksum: Adler-32 variant for O(1) window sliding
  • Strong Hash: BLAKE3 for cryptographic block verification
  • Delta Encoding: Efficient representation of file differences
  • Streaming: O(1) memory for arbitrary file sizes

§Example

use copia::{SyncBuilder, Sync};
use std::io::Cursor;

// Create sync engine with custom block size
let sync = SyncBuilder::new()
    .block_size(2048)
    .build();

// Generate signature from basis file
let basis = b"original file content";
let signature = sync.signature(Cursor::new(basis.as_slice())).unwrap();

// Compute delta from modified source
let source = b"modified file content";
let delta = sync.delta(Cursor::new(source.as_slice()), &signature).unwrap();

// Apply delta to reconstruct
let mut output = Vec::new();
sync.patch(Cursor::new(basis.as_slice()), &delta, &mut output).unwrap();
assert_eq!(output, source);

Modules§

async_sync
Async synchronization operations using tokio.

Structs§

BlockSignature
Signature for a single block in the basis file.
Codec
Protocol codec for reading/writing framed messages.
CopiaSync
Main synchronization engine implementing the rsync algorithm.
Delta
Encoded delta representing the difference between source and basis files.
DeltaStats
Statistics from delta computation.
FastRollingChecksum
High-performance rolling checksum with lazy modulo operations.
FrameBuilder
Frame builder for constructing protocol frames.
FrameHeader
Protocol frame header.
RollingChecksum
Rolling checksum state for incremental computation.
Signature
Complete signature of a basis file.
SignatureTable
Efficient lookup table for block matching.
StrongHash
Strong cryptographic hash for block verification.
SyncBuilder
Builder for creating sync engines with custom configuration.
SyncConfig
Configuration for sync operations.
SyncStats
Statistics from a sync operation.

Enums§

CopiaError
Errors that can occur during copia operations.
DeltaOp
Delta instruction types.
Message
Protocol messages.
MessageType
Protocol message types.

Constants§

PROTOCOL_MAGIC
Protocol magic bytes: “COPA”
PROTOCOL_VERSION
Current protocol version.

Traits§

Sync
Core synchronization operations trait.

Type Aliases§

Result
Result type for copia operations.