···1010[docs-badge]: https://docs.rs/repo-stream/badge.svg
1111[sponsor-badge]: https://img.shields.io/badge/at-microcosm-b820f9?labelColor=b820f9&logo=githubsponsors&logoColor=fff
12121313-```rust
1313+```rust no_run
1414use repo_stream::{Driver, DriverBuilder, DriveError, DiskBuilder};
15151616#[tokio::main]
1717-async fn main() -> Result<(), DriveError> {
1717+async fn main() -> Result<(), Box<dyn std::error::Error>> {
1818 // repo-stream takes any AsyncRead as input, like a tokio::fs::File
1919- let reader = tokio::fs::File::open("repo.car".into()).await?;
1919+ let reader = tokio::fs::File::open("repo.car").await?;
2020 let reader = tokio::io::BufReader::new(reader);
21212222 // example repo workload is simply counting the total record bytes
···24242525 match DriverBuilder::new()
2626 .with_mem_limit_mb(10)
2727- .with_block_processor(|rec| rec.len()) // block processing: just extract the raw record size
2727+ .with_block_processor( // block processing: just extract the raw record size
2828+ |rec| rec.len().to_ne_bytes().to_vec())
2829 .load_car(reader)
2930 .await?
3031 {
···3233 // if all blocks fit within memory
3334 Driver::Memory(_commit, mut driver) => {
3435 while let Some(chunk) = driver.next_chunk(256).await? {
3535- for (_rkey, size) in chunk {
3636+ for (_rkey, processed) in chunk {
3737+ let size = usize::from_ne_bytes(processed.try_into().unwrap());
3638 total_size += size;
3739 }
3840 }
···4648 let (_commit, mut driver) = paused.finish_loading(store).await?;
47494850 while let Some(chunk) = driver.next_chunk(256).await? {
4949- for (_rkey, size) in chunk {
5151+ for (_rkey, processed) in chunk {
5252+ let size = usize::from_ne_bytes(processed.try_into().unwrap());
5053 total_size += size;
5154 }
5255 }
+7-8
src/lib.rs
···2828match DriverBuilder::new()
2929 .with_mem_limit_mb(10)
3030 .with_block_processor(
3131- |rec| rec.len().to_ne_bytes().to_vec().into()
3131+ |rec| rec.len().to_ne_bytes().to_vec()
3232 ) // block processing: just extract the raw record size
3333 .load_car(reader)
3434 .await?
···3838 Driver::Memory(_commit, mut driver) => {
3939 while let Some(chunk) = driver.next_chunk(256).await? {
4040 for (_rkey, bytes) in chunk {
4141-4242- let (int_bytes, _) = bytes.split_at(size_of::<usize>());
4343- let size = usize::from_ne_bytes(int_bytes.try_into().unwrap());
4141+ let size = usize::from_ne_bytes(bytes.try_into().unwrap());
44424543 total_size += size;
4644 }
···56545755 while let Some(chunk) = driver.next_chunk(256).await? {
5856 for (_rkey, bytes) in chunk {
5959-6060- let (int_bytes, _) = bytes.split_at(size_of::<usize>());
6161- let size = usize::from_ne_bytes(int_bytes.try_into().unwrap());
5757+ let size = usize::from_ne_bytes(bytes.try_into().unwrap());
62586359 total_size += size;
6460 }
···9187pub use drive::{DriveError, Driver, DriverBuilder, NeedDisk, noop};
9288pub use mst::Commit;
93899494-// pub use bytes::Bytes;
9590pub type Bytes = Vec<u8>;
96919792pub(crate) use hashbrown::HashMap;
9393+9494+#[doc = include_str!("../readme.md")]
9595+#[cfg(doctest)]
9696+pub struct ReadmeDoctests;