Crates.io | delta_rs |
lib.rs | delta_rs |
version | 0.1.1 |
source | src |
created_at | 2023-10-27 09:17:56.534144 |
updated_at | 2023-10-27 09:47:32.683605 |
description | A version control and incremental data storage tool based on Rust, |
homepage | https://github.com/sonichen/delta_rs |
repository | https://github.com/sonichen/delta_rs |
max_upload_size | |
id | 1015812 |
size | 13,373 |
delta_rs
is a version control and incremental data storage tool based on Rust, allowing you to store only data blocks that have not been stored in previous versions, effectively managing and restoring different versions of data.
The design of delta_rs is centered around the following key principles:
Version Control: The project allows users to maintain and manage multiple versions of data. Each version is represented as a Delta.
Incremental Data Storage: To reduce storage space usage, delta_rs stores only the data blocks that have not been stored in previous versions. This is achieved through a block-based approach.
Block-Based Storage: Data is divided into blocks, and each block is associated with a unique identifier. When a new version is created, only the new and previously unsaved blocks are stored, along with the composition order. This design minimizes redundant data storage.
Quick Data Restoration: Users can efficiently restore data to a specific version by specifying the version number and data block index.
Delta_rs is designed to be useful in various scenarios, including:
Add delta_rs as a dependency in your Cargo.toml:
[dependencies]
delta_rs = "0.1.1"
use delta_rs::{ get_content, Deltas};
fn main() {
// Write data
let mut deltas=Deltas::create("Hello, I am a rust developer.");
// First modify
deltas.modify("Hello, I am a Java developer.");
// Second modify
deltas.modify("Hello, I am a Python developer.");
// Third modify
deltas.modify("Hello, I am a Go developer.");
// print the data block and the content
for item in &deltas.deltas {
println!("{}", get_content(item.id, deltas.deltas.clone()));
println!("{:?}\n", item);
}
}
Output
Hello, I am a rust developer.
Delta { id: 0, index: [0, 1, 2], blocks: [DataBlock { block_number: 0, data: [72, 101, 108, 108, 111, 44, 32, 73, 32, 97] }, DataBlock { block_number: 1, data: [109, 32, 97, 32, 114, 117, 115, 116, 32, 100] }, DataBlock { block_number: 2, data: [101, 118, 101, 108, 111, 112, 101, 114, 46] }], snapshot: true }
Hello, I am a Java developer.
Delta { id: 1, index: [0, 3, 2], blocks: [DataBlock { block_number: 3, data: [109, 32, 97, 32, 74, 97, 118, 97, 32, 100] }], snapshot: true }
Hello, I am a Python developer.
Delta { id: 2, index: [0, 4, 5, 6], blocks: [DataBlock { block_number: 4, data: [109, 32, 97, 32, 80, 121, 116, 104, 111, 110] }, DataBlock { block_number: 5, data: [32, 100, 101, 118, 101, 108, 111, 112, 101, 114] }, DataBlock { block_number: 6, data: [46] }], snapshot: true }
Hello, I am a Go developer.
Delta { id: 3, index: [0, 7, 8], blocks: [DataBlock { block_number: 7, data: [109, 32, 97, 32, 71, 111, 32, 100, 101, 118] }, DataBlock { block_number: 8, data: [101, 108, 111, 112, 101, 114, 46] }], snapshot: true }
delta_rs
is licensed under this licensed: