STreaming ARchives: stricter, verifiable, deterministic, highly compressible alternatives to CAR files for atproto repositories.
atproto car
9
fork

Configure Feed

Select the types of activity you want to include in your feed.

some examples

phil 22b4dd50 555c5a2a

+538 -10
+313 -5
Cargo.lock
··· 3 3 version = 4 4 4 5 5 [[package]] 6 + name = "addr2line" 7 + version = "0.25.1" 8 + source = "registry+https://github.com/rust-lang/crates.io-index" 9 + checksum = "1b5d307320b3181d6d7954e663bd7c774a838b8220fe0593c86d9fb09f498b4b" 10 + dependencies = [ 11 + "gimli", 12 + ] 13 + 14 + [[package]] 15 + name = "adler2" 16 + version = "2.0.1" 17 + source = "registry+https://github.com/rust-lang/crates.io-index" 18 + checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" 19 + 20 + [[package]] 21 + name = "anyhow" 22 + version = "1.0.100" 23 + source = "registry+https://github.com/rust-lang/crates.io-index" 24 + checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" 25 + dependencies = [ 26 + "backtrace", 27 + ] 28 + 29 + [[package]] 30 + name = "backtrace" 31 + version = "0.3.76" 32 + source = "registry+https://github.com/rust-lang/crates.io-index" 33 + checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6" 34 + dependencies = [ 35 + "addr2line", 36 + "cfg-if", 37 + "libc", 38 + "miniz_oxide", 39 + "object", 40 + "rustc-demangle", 41 + "windows-link", 42 + ] 43 + 44 + [[package]] 6 45 name = "base-x" 7 46 version = "0.2.11" 8 47 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 19 58 ] 20 59 21 60 [[package]] 61 + name = "bitflags" 62 + version = "2.10.0" 63 + source = "registry+https://github.com/rust-lang/crates.io-index" 64 + checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" 65 + 66 + [[package]] 22 67 name = "block-buffer" 23 68 version = "0.10.4" 24 69 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 59 104 "multihash", 60 105 "serde", 61 106 "serde_bytes", 62 - "unsigned-varint", 107 + "unsigned-varint 0.8.0", 63 108 ] 64 109 65 110 [[package]] ··· 133 178 ] 134 179 135 180 [[package]] 181 + name = "errno" 182 + version = "0.3.14" 183 + source = "registry+https://github.com/rust-lang/crates.io-index" 184 + checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" 185 + dependencies = [ 186 + "libc", 187 + "windows-sys 0.61.2", 188 + ] 189 + 190 + [[package]] 136 191 name = "futures" 137 192 version = "0.3.31" 138 193 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 232 287 ] 233 288 234 289 [[package]] 290 + name = "gimli" 291 + version = "0.32.3" 292 + source = "registry+https://github.com/rust-lang/crates.io-index" 293 + checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" 294 + 295 + [[package]] 235 296 name = "ipld-core" 236 297 version = "0.4.2" 237 298 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 243 304 ] 244 305 245 306 [[package]] 307 + name = "iroh-car" 308 + version = "0.5.1" 309 + source = "registry+https://github.com/rust-lang/crates.io-index" 310 + checksum = "cb7f8cd4cb9aa083fba8b52e921764252d0b4dcb1cd6d120b809dbfe1106e81a" 311 + dependencies = [ 312 + "anyhow", 313 + "cid", 314 + "futures", 315 + "serde", 316 + "serde_ipld_dagcbor", 317 + "thiserror 1.0.69", 318 + "tokio", 319 + "unsigned-varint 0.7.2", 320 + ] 321 + 322 + [[package]] 246 323 name = "libc" 247 324 version = "0.2.180" 248 325 source = "registry+https://github.com/rust-lang/crates.io-index" 249 326 checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" 250 327 251 328 [[package]] 329 + name = "lock_api" 330 + version = "0.4.14" 331 + source = "registry+https://github.com/rust-lang/crates.io-index" 332 + checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" 333 + dependencies = [ 334 + "scopeguard", 335 + ] 336 + 337 + [[package]] 252 338 name = "match-lookup" 253 339 version = "0.1.2" 254 340 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 266 352 checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" 267 353 268 354 [[package]] 355 + name = "miniz_oxide" 356 + version = "0.8.9" 357 + source = "registry+https://github.com/rust-lang/crates.io-index" 358 + checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" 359 + dependencies = [ 360 + "adler2", 361 + ] 362 + 363 + [[package]] 364 + name = "mio" 365 + version = "1.1.1" 366 + source = "registry+https://github.com/rust-lang/crates.io-index" 367 + checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" 368 + dependencies = [ 369 + "libc", 370 + "wasi", 371 + "windows-sys 0.61.2", 372 + ] 373 + 374 + [[package]] 269 375 name = "multibase" 270 376 version = "0.9.2" 271 377 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 285 391 dependencies = [ 286 392 "core2", 287 393 "serde", 288 - "unsigned-varint", 394 + "unsigned-varint 0.8.0", 395 + ] 396 + 397 + [[package]] 398 + name = "object" 399 + version = "0.37.3" 400 + source = "registry+https://github.com/rust-lang/crates.io-index" 401 + checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe" 402 + dependencies = [ 403 + "memchr", 404 + ] 405 + 406 + [[package]] 407 + name = "parking_lot" 408 + version = "0.12.5" 409 + source = "registry+https://github.com/rust-lang/crates.io-index" 410 + checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" 411 + dependencies = [ 412 + "lock_api", 413 + "parking_lot_core", 414 + ] 415 + 416 + [[package]] 417 + name = "parking_lot_core" 418 + version = "0.9.12" 419 + source = "registry+https://github.com/rust-lang/crates.io-index" 420 + checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" 421 + dependencies = [ 422 + "cfg-if", 423 + "libc", 424 + "redox_syscall", 425 + "smallvec", 426 + "windows-link", 289 427 ] 290 428 291 429 [[package]] ··· 317 455 dependencies = [ 318 456 "proc-macro2", 319 457 ] 458 + 459 + [[package]] 460 + name = "redox_syscall" 461 + version = "0.5.18" 462 + source = "registry+https://github.com/rust-lang/crates.io-index" 463 + checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" 464 + dependencies = [ 465 + "bitflags", 466 + ] 467 + 468 + [[package]] 469 + name = "rustc-demangle" 470 + version = "0.1.27" 471 + source = "registry+https://github.com/rust-lang/crates.io-index" 472 + checksum = "b50b8869d9fc858ce7266cce0194bd74df58b9d0e3f6df3a9fc8eb470d95c09d" 320 473 321 474 [[package]] 322 475 name = "scopeguard" ··· 388 541 ] 389 542 390 543 [[package]] 544 + name = "signal-hook-registry" 545 + version = "1.4.8" 546 + source = "registry+https://github.com/rust-lang/crates.io-index" 547 + checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" 548 + dependencies = [ 549 + "errno", 550 + "libc", 551 + ] 552 + 553 + [[package]] 391 554 name = "slab" 392 555 version = "0.4.11" 393 556 source = "registry+https://github.com/rust-lang/crates.io-index" 394 557 checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" 395 558 396 559 [[package]] 560 + name = "smallvec" 561 + version = "1.15.1" 562 + source = "registry+https://github.com/rust-lang/crates.io-index" 563 + checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" 564 + 565 + [[package]] 566 + name = "socket2" 567 + version = "0.6.1" 568 + source = "registry+https://github.com/rust-lang/crates.io-index" 569 + checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" 570 + dependencies = [ 571 + "libc", 572 + "windows-sys 0.60.2", 573 + ] 574 + 575 + [[package]] 397 576 name = "star" 398 577 version = "0.1.0" 399 578 dependencies = [ 579 + "anyhow", 400 580 "bytes", 401 581 "cid", 402 582 "futures", 583 + "iroh-car", 403 584 "serde", 404 585 "serde_bytes", 405 586 "serde_ipld_dagcbor", 406 587 "sha2", 407 - "thiserror", 588 + "thiserror 2.0.18", 408 589 "tokio", 409 590 "tokio-util", 410 - "unsigned-varint", 591 + "unsigned-varint 0.8.0", 411 592 ] 412 593 413 594 [[package]] ··· 423 604 424 605 [[package]] 425 606 name = "thiserror" 607 + version = "1.0.69" 608 + source = "registry+https://github.com/rust-lang/crates.io-index" 609 + checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" 610 + dependencies = [ 611 + "thiserror-impl 1.0.69", 612 + ] 613 + 614 + [[package]] 615 + name = "thiserror" 426 616 version = "2.0.18" 427 617 source = "registry+https://github.com/rust-lang/crates.io-index" 428 618 checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" 429 619 dependencies = [ 430 - "thiserror-impl", 620 + "thiserror-impl 2.0.18", 621 + ] 622 + 623 + [[package]] 624 + name = "thiserror-impl" 625 + version = "1.0.69" 626 + source = "registry+https://github.com/rust-lang/crates.io-index" 627 + checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" 628 + dependencies = [ 629 + "proc-macro2", 630 + "quote", 631 + "syn", 431 632 ] 432 633 433 634 [[package]] ··· 448 649 checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86" 449 650 dependencies = [ 450 651 "bytes", 652 + "libc", 653 + "mio", 654 + "parking_lot", 451 655 "pin-project-lite", 656 + "signal-hook-registry", 657 + "socket2", 452 658 "tokio-macros", 659 + "windows-sys 0.61.2", 453 660 ] 454 661 455 662 [[package]] ··· 490 697 491 698 [[package]] 492 699 name = "unsigned-varint" 700 + version = "0.7.2" 701 + source = "registry+https://github.com/rust-lang/crates.io-index" 702 + checksum = "6889a77d49f1f013504cec6bf97a2c730394adedaeb1deb5ea08949a50541105" 703 + 704 + [[package]] 705 + name = "unsigned-varint" 493 706 version = "0.8.0" 494 707 source = "registry+https://github.com/rust-lang/crates.io-index" 495 708 checksum = "eb066959b24b5196ae73cb057f45598450d2c5f71460e98c49b738086eff9c06" ··· 499 712 version = "0.9.5" 500 713 source = "registry+https://github.com/rust-lang/crates.io-index" 501 714 checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" 715 + 716 + [[package]] 717 + name = "wasi" 718 + version = "0.11.1+wasi-snapshot-preview1" 719 + source = "registry+https://github.com/rust-lang/crates.io-index" 720 + checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" 721 + 722 + [[package]] 723 + name = "windows-link" 724 + version = "0.2.1" 725 + source = "registry+https://github.com/rust-lang/crates.io-index" 726 + checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" 727 + 728 + [[package]] 729 + name = "windows-sys" 730 + version = "0.60.2" 731 + source = "registry+https://github.com/rust-lang/crates.io-index" 732 + checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" 733 + dependencies = [ 734 + "windows-targets", 735 + ] 736 + 737 + [[package]] 738 + name = "windows-sys" 739 + version = "0.61.2" 740 + source = "registry+https://github.com/rust-lang/crates.io-index" 741 + checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" 742 + dependencies = [ 743 + "windows-link", 744 + ] 745 + 746 + [[package]] 747 + name = "windows-targets" 748 + version = "0.53.5" 749 + source = "registry+https://github.com/rust-lang/crates.io-index" 750 + checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" 751 + dependencies = [ 752 + "windows-link", 753 + "windows_aarch64_gnullvm", 754 + "windows_aarch64_msvc", 755 + "windows_i686_gnu", 756 + "windows_i686_gnullvm", 757 + "windows_i686_msvc", 758 + "windows_x86_64_gnu", 759 + "windows_x86_64_gnullvm", 760 + "windows_x86_64_msvc", 761 + ] 762 + 763 + [[package]] 764 + name = "windows_aarch64_gnullvm" 765 + version = "0.53.1" 766 + source = "registry+https://github.com/rust-lang/crates.io-index" 767 + checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" 768 + 769 + [[package]] 770 + name = "windows_aarch64_msvc" 771 + version = "0.53.1" 772 + source = "registry+https://github.com/rust-lang/crates.io-index" 773 + checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" 774 + 775 + [[package]] 776 + name = "windows_i686_gnu" 777 + version = "0.53.1" 778 + source = "registry+https://github.com/rust-lang/crates.io-index" 779 + checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" 780 + 781 + [[package]] 782 + name = "windows_i686_gnullvm" 783 + version = "0.53.1" 784 + source = "registry+https://github.com/rust-lang/crates.io-index" 785 + checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" 786 + 787 + [[package]] 788 + name = "windows_i686_msvc" 789 + version = "0.53.1" 790 + source = "registry+https://github.com/rust-lang/crates.io-index" 791 + checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" 792 + 793 + [[package]] 794 + name = "windows_x86_64_gnu" 795 + version = "0.53.1" 796 + source = "registry+https://github.com/rust-lang/crates.io-index" 797 + checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" 798 + 799 + [[package]] 800 + name = "windows_x86_64_gnullvm" 801 + version = "0.53.1" 802 + source = "registry+https://github.com/rust-lang/crates.io-index" 803 + checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" 804 + 805 + [[package]] 806 + name = "windows_x86_64_msvc" 807 + version = "0.53.1" 808 + source = "registry+https://github.com/rust-lang/crates.io-index" 809 + checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
+16 -2
Cargo.toml
··· 9 9 async = ["dep:tokio", "dep:tokio-util", "dep:futures", "dep:bytes"] 10 10 11 11 [dependencies] 12 - # Core 13 12 serde = { version = "1", features = ["derive"] } 14 13 serde_ipld_dagcbor = "0.6" 15 14 serde_bytes = "0.11" ··· 18 17 sha2 = "0.10" 19 18 unsigned-varint = "0.8" 20 19 21 - # Async 20 + # async 22 21 bytes = { version = "1", optional = true } 23 22 tokio = { version = "1", features = ["io-util", "macros", "rt"], optional = true } 24 23 tokio-util = { version = "0.7", features = ["codec"], optional = true } 25 24 futures = { version = "0.3", optional = true } 25 + 26 + [dev-dependencies] 27 + anyhow = { version = "1.0.100", features = ["backtrace"] } 28 + tokio = { version = "1", features = ["full"] } 29 + iroh-car = "0.5.1" 30 + 31 + [[example]] 32 + name = "star-debug" 33 + path = "src/examples/star-debug.rs" 34 + required-features = ["blocking"] 35 + 36 + [[example]] 37 + name = "car-to-star" 38 + path = "src/examples/car-to-star.rs" 39 + required-features = ["async"]
car-samples/empty.car

This is a binary file and will not be displayed.

car-samples/little.car

This is a binary file and will not be displayed.

car-samples/slice-node-after.car

This is a binary file and will not be displayed.

car-samples/slice-node-first-key.car

This is a binary file and will not be displayed.

car-samples/slice-one.car

This is a binary file and will not be displayed.

car-samples/slice-proving-absence.car

This is a binary file and will not be displayed.

car-samples/tiny.car

This is a binary file and will not be displayed.

+141
src/examples/car-to-star.rs
··· 1 + use anyhow::{Context, Result}; 2 + use cid::Cid; 3 + use iroh_car::CarReader; 4 + use star::{RepoMstNode, StarCommit, StarMstEntry, StarMstNode, StarSerializer, calculate_height}; 5 + use std::collections::HashMap; 6 + use std::env; 7 + 8 + #[tokio::main] 9 + async fn main() -> Result<()> { 10 + let args: Vec<String> = env::args().collect(); 11 + if args.len() != 3 { 12 + eprintln!("Usage: car-to-star <input.car> <output.star>"); 13 + std::process::exit(1); 14 + } 15 + 16 + let car_path = &args[1]; 17 + let star_path = &args[2]; 18 + 19 + let reader = tokio::fs::File::open(car_path).await?; 20 + let reader = tokio::io::BufReader::new(reader); 21 + 22 + println!("Reading CAR file..."); 23 + let mut car = CarReader::new(reader).await?; 24 + let roots = car.header().roots(); 25 + assert_eq!(roots.len(), 1); 26 + 27 + let commit_cid = *roots.first().expect("a root to be present"); 28 + 29 + let mut blocks: HashMap<Cid, Vec<u8>> = HashMap::new(); 30 + 31 + while let Some((cid, data)) = car.next_block().await? { 32 + blocks.insert(cid, data); 33 + } 34 + println!("Loaded {} blocks.", blocks.len()); 35 + 36 + let output_file = std::fs::File::create(star_path)?; 37 + 38 + let commit_bytes = blocks.get(&commit_cid).context("Commit block not found")?; 39 + 40 + #[derive(serde::Deserialize)] 41 + struct RepoCommit { 42 + did: String, 43 + version: i64, 44 + data: Cid, 45 + rev: String, 46 + prev: Option<Cid>, 47 + sig: Option<serde_bytes::ByteBuf>, 48 + } 49 + 50 + let repo_commit: RepoCommit = serde_ipld_dagcbor::from_slice(commit_bytes)?; 51 + 52 + let star_commit = StarCommit { 53 + did: repo_commit.did, 54 + version: repo_commit.version, 55 + data: Some(repo_commit.data), 56 + rev: repo_commit.rev, 57 + prev: repo_commit.prev, 58 + sig: repo_commit.sig, 59 + }; 60 + 61 + let mut serializer = StarSerializer::new(output_file); 62 + 63 + serializer.write_header(&star_commit)?; 64 + println!("wrote header. Root: {}", repo_commit.data); 65 + println!("writing tree..."); 66 + let (nodes, records) = write_tree(repo_commit.data, &blocks, &mut serializer)?; 67 + println!("wrote {nodes} nodes and {records} records."); 68 + 69 + serializer.finish()?; 70 + println!("Done!"); 71 + Ok(()) 72 + } 73 + 74 + fn write_tree( 75 + node_cid: Cid, 76 + blocks: &HashMap<Cid, Vec<u8>>, 77 + serializer: &mut StarSerializer<std::fs::File>, 78 + ) -> Result<(usize, usize)> { 79 + // println!("writing tree under {node_cid:?}..."); 80 + 81 + let mut nodes_written = 0; 82 + let mut records_written = 0; 83 + 84 + let block_bytes = blocks 85 + .get(&node_cid) 86 + .with_context(|| format!("Missing block {}", node_cid))?; 87 + 88 + let repo_node: RepoMstNode = serde_ipld_dagcbor::from_slice(block_bytes)?; 89 + 90 + let height = if let Some(first_entry) = repo_node.e.first() { 91 + calculate_height(&first_entry.k) 92 + } else { 93 + 0 94 + }; 95 + 96 + let star_node = StarMstNode { 97 + l: repo_node.l, 98 + l_archived: repo_node.l.map(|_| true), 99 + e: repo_node 100 + .e 101 + .iter() 102 + .map(|e| { 103 + let v = if height == 0 { None } else { Some(e.v) }; 104 + StarMstEntry { 105 + p: e.p, 106 + k: e.k.clone(), 107 + v, 108 + v_archived: Some(true), 109 + t: e.t, 110 + t_archived: e.t.map(|_| true), 111 + } 112 + }) 113 + .collect(), 114 + }; 115 + 116 + serializer.write_node(&star_node)?; 117 + nodes_written += 1; 118 + 119 + if let Some(l_cid) = repo_node.l { 120 + let (n, r) = write_tree(l_cid, blocks, serializer)?; 121 + nodes_written += n; 122 + records_written += r; 123 + } 124 + 125 + for e in repo_node.e { 126 + let record_bytes = blocks 127 + .get(&e.v) 128 + .with_context(|| format!("Missing record {}", e.v))?; 129 + // eprintln!("writing record {:?} (<= {node_cid:?})", e.v); 130 + serializer.write_record(record_bytes)?; 131 + records_written += 1; 132 + 133 + if let Some(t_cid) = e.t { 134 + let (n, r) = write_tree(t_cid, blocks, serializer)?; 135 + nodes_written += n; 136 + records_written += r; 137 + } 138 + } 139 + 140 + Ok((nodes_written, records_written)) 141 + }
+64
src/examples/star-debug.rs
··· 1 + use star::{StarItem, StarIterator, StarMstNode}; 2 + use std::env; 3 + use std::fs::File; 4 + use std::io::BufReader; 5 + 6 + fn main() -> Result<(), Box<dyn std::error::Error>> { 7 + let args: Vec<String> = env::args().collect(); 8 + if args.len() != 2 { 9 + eprintln!("Usage: star-debug <file.star>"); 10 + std::process::exit(1); 11 + } 12 + 13 + let file = File::open(&args[1])?; 14 + let reader = BufReader::new(file); 15 + let iter = StarIterator::new(reader); 16 + 17 + for item in iter.iter_tree() { 18 + let item = item?; 19 + match item { 20 + StarItem::Commit(c) => { 21 + println!("Commit:"); 22 + println!(" DID: {}", c.did); 23 + println!(" Rev: {}", c.rev); 24 + println!(" Root: {:?}", c.data); 25 + } 26 + StarItem::Node(n) => { 27 + // print_node(&n); 28 + } 29 + StarItem::Record { key, cid, .. } => { 30 + // println!(" Record: key={}, cid={}", to_hex(&key), cid); 31 + } 32 + } 33 + } 34 + 35 + Ok(()) 36 + } 37 + 38 + fn print_node(node: &StarMstNode) { 39 + println!("Node:"); 40 + if let Some(l) = node.l { 41 + println!(" Left -> {}", l); 42 + } 43 + for (i, e) in node.e.iter().enumerate() { 44 + print!(" Entry {}: key={}", i, to_hex(&e.k)); 45 + if let Some(v) = e.v { 46 + print!(", val={}", v); 47 + } else { 48 + print!(", val=(implicit)"); 49 + } 50 + if let Some(t) = e.t { 51 + print!(", right->{}", t); 52 + } 53 + println!(); 54 + } 55 + } 56 + 57 + fn to_hex(bytes: &[u8]) -> String { 58 + let mut s = String::with_capacity(bytes.len() * 2); 59 + for b in bytes { 60 + use std::fmt::Write; 61 + write!(&mut s, "{:02x}", b).unwrap(); 62 + } 63 + s 64 + }
+4 -1
src/lib.rs
··· 13 13 pub use error::{Result, StarError}; 14 14 pub use parser::StarParser; 15 15 pub use ser::{StarEncoder, StarSerializer, StarValidator}; 16 - pub use types::{RepoMstEntry, RepoMstNode, StarCommit, StarItem, StarMstEntry, StarMstNode}; 16 + pub use types::{ 17 + RepoMstEntry, RepoMstNode, StarCommit, StarItem, StarMstEntry, StarMstNode, calculate_height, 18 + }; 19 + pub use validation::validate_node_structure; 17 20 18 21 #[cfg(feature = "blocking")] 19 22 pub use blocking::StarIterator;
-2
src/types.rs
··· 50 50 /// The Canonical MST Node object (for CID calculation) 51 51 #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] 52 52 pub struct RepoMstNode { 53 - #[serde(default, skip_serializing_if = "Option::is_none")] 54 53 pub l: Option<Cid>, 55 54 pub e: Vec<RepoMstEntry>, 56 55 } ··· 61 60 pub p: u32, 62 61 pub k: ByteBuf, 63 62 pub v: Cid, // Required in Repo spec 64 - #[serde(default, skip_serializing_if = "Option::is_none")] 65 63 pub t: Option<Cid>, 66 64 } 67 65
star-samples/empty.star

This is a binary file and will not be displayed.

star-samples/little.star

This is a binary file and will not be displayed.

star-samples/tiny.star

This is a binary file and will not be displayed.