6 releases

0.3.1 Dec 7, 2021
0.3.0 Jul 1, 2020
0.2.0 Jun 13, 2020
0.1.2 Jan 28, 2019
0.1.1 Sep 26, 2018

#63 in No standard library

Download history 2197/week @ 2024-07-30 2695/week @ 2024-08-06 1462/week @ 2024-08-13 2042/week @ 2024-08-20 1491/week @ 2024-08-27 2191/week @ 2024-09-03 1410/week @ 2024-09-10 3506/week @ 2024-09-17 3393/week @ 2024-09-24 2158/week @ 2024-10-01 4354/week @ 2024-10-08 2529/week @ 2024-10-15 2728/week @ 2024-10-22 2139/week @ 2024-10-29 1494/week @ 2024-11-05 2454/week @ 2024-11-12

9,110 downloads per month
Used in 116 crates (17 directly)

MIT/Apache

14KB
273 lines

Iterators over a simple binary blob storage.

Storage format

Storage format represents a sequence of binary blobs. The format uses git-flavored variable-length quantity (VLQ) for encoding unsigned numbers.

File starts with a number of de-duplicated blobs d. It followed by d entries. Each entry starts with an integer m, immediately folowed by m bytes representing de-duplicated binary blob.

Next follows unspecified number of entries representing sequence of stored blobs. Each entry starts with an unsigned integer n. The least significant bit of this integer is used as a flag. If the flag is equal to 0, then the number is followed by n >> 1 bytes, representing a stored binary blob. Otherwise the entry references a de-duplicated entry number n >> 1.

Examples

let buf = b"\x02\x05hello\x06world!\x01\x02 \x00\x03\x06:::\x03\x01\x00";
let mut v = blobby::BlobIterator::new(buf).unwrap();
assert_eq!(v.next(), Some(Ok(&b"hello"[..])));
assert_eq!(v.next(), Some(Ok(&b" "[..])));
assert_eq!(v.next(), Some(Ok(&b""[..])));
assert_eq!(v.next(), Some(Ok(&b"world!"[..])));
assert_eq!(v.next(), Some(Ok(&b":::"[..])));
assert_eq!(v.next(), Some(Ok(&b"world!"[..])));
assert_eq!(v.next(), Some(Ok(&b"hello"[..])));
assert_eq!(v.next(), Some(Ok(&b""[..])));
assert_eq!(v.next(), None);

let mut v = blobby::Blob2Iterator::new(buf).unwrap();
assert_eq!(v.next(), Some(Ok([&b"hello"[..], b" "])));
assert_eq!(v.next(), Some(Ok([&b""[..], b"world!"])));
assert_eq!(v.next(), Some(Ok([&b":::"[..], b"world!"])));
assert_eq!(v.next(), Some(Ok([&b"hello"[..], b""])));
assert_eq!(v.next(), None);

let mut v = blobby::Blob4Iterator::new(buf).unwrap();
assert_eq!(v.next(), Some(Ok([&b"hello"[..], b" ", b"", b"world!"])));
assert_eq!(v.next(), Some(Ok([&b":::"[..], b"world!", b"hello", b""])));
assert_eq!(v.next(), None);

No runtime deps