https://github.com/scttnlsn/blobstore
Content addressable blob store
https://github.com/scttnlsn/blobstore
blob-store content-addressable-storage rust
Last synced: 6 months ago
JSON representation
Content addressable blob store
- Host: GitHub
- URL: https://github.com/scttnlsn/blobstore
- Owner: scttnlsn
- Created: 2018-02-15T02:07:58.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-02T03:55:44.000Z (almost 8 years ago)
- Last Synced: 2025-05-29T06:54:33.702Z (7 months ago)
- Topics: blob-store, content-addressable-storage, rust
- Language: Rust
- Size: 8.79 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# blobstore
[](https://travis-ci.org/scttnlsn/blobstore)
[](https://crates.io/crates/blobstore)
A content addressable store for arbitrary blobs.
## Usage
Add the following to your `Cargo.toml` file:
```toml
[dependencies]
blobstore = "*"
```
and import into your code:
```rust
extern crate blobstore;
```
## Example
```rust
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:
```rust
trait Store {
fn put(&self, item: &mut std::io::Read) -> Result;
fn get(&self, hash: &str) -> Result;
fn remove(&self, hash: &str) -> Result<(), std::io::Error>;
}
```