Skip to main content

Module builder

Module builder 

Source
Expand description

Build an Odb with a custom primary store and optional read overlays.

§Example

use std::sync::Arc;

use grit_lib::objects::{HashAlgo, ObjectKind};
use grit_lib::objects::odb::store::{MemoryStore, WritableObjectStore};
use grit_lib::objects::odb::{Odb, OdbBuilder, WriteOptions};

let store = Arc::new(MemoryStore::new(HashAlgo::Sha1));
let odb = OdbBuilder::files("/tmp/repo/.git/objects")
    .primary(store.clone())
    .alternates(false)
    .build();
let oid = WritableObjectStore::write(odb.primary_writable().unwrap().as_ref(), ObjectKind::Blob, b"hi", WriteOptions::default()).unwrap();
assert_eq!(oid.to_hex().len(), 40);

Structs§

OdbBuilder
Configure and construct an Odb with a pluggable primary backend.