blobstore 0.1.1

content addressable blob store
Documentation
  • Coverage
  • 0%
    0 out of 7 items documented0 out of 6 items with examples
  • Size
  • Source code size: 10.96 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 708.9 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 30s Average build duration of successful builds.
  • all releases: 30s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • scttnlsn/blobstore
    4 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • scttnlsn

blobstore

Travis CI Status crates.io

A content addressable store for arbitrary blobs.

Usage

Add the following to your Cargo.toml file:

[dependencies]
blobstore = "*"

and import into your code:

extern crate blobstore;

Example

extern crate blobstore;

use blobstore::BlobStore;

let mut data = "foo".as_bytes();
let store = BlobStore::new("./store".to_string());

// this will accept any `std::io::Read` type
let hash = store.put(&mut data).unwrap();

// hash is a SHA256 of the content
assert_eq!(hash, "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae");

let mut value = String::new();
store.get(hash.as_ref()).unwrap().read_to_string(&mut value).unwrap();

assert_eq!(value, "foo");

store.remove(hash.as_ref()).unwrap();

fs::remove_dir_all(store.path).unwrap();

API

BlobStore implements the following trait:

trait Store {
    fn put(&self, item: &mut std::io::Read) -> Result<String, std::io::Error>;
    fn get(&self, hash: &str) -> Result<stf::fs::File, std::io::Error>;
    fn remove(&self, hash: &str) -> Result<(), std::io::Error>;
}