Struct git_odb::loose::Db[][src]

pub struct Db {
    pub path: PathBuf,
}

A database for reading and writing objects to disk, one file per object.

Fields

path: PathBuf

The directory in which objects are stored, containing 256 folders representing the hashes first byte.

Implementations

impl Db[src]

Iteration and traversal

pub fn iter(&self) -> Type[src]

Return an iterator over all objects contained in the database.

The Ids returned by the iterator can typically be used in the locate(…) method. Note that the result is not sorted or stable, thus ordering can change between runs.

Notes

IterType is used instead of impl Iterator<…> to allow using this iterator in struct fields, as is currently needed if iterators need to be implemented by hand in the absence of generators.

impl Db[src]

Object lookup

pub fn contains(&self, id: impl AsRef<oid>) -> bool[src]

Returns true if the given id is contained in our repository.

pub fn locate<'a>(
    &self,
    id: impl AsRef<oid>,
    out: &'a mut Vec<u8>
) -> Result<Option<Object<'a>>, Error>
[src]

Return the object identified by the given ObjectId if present in this database, writing its raw data into the given out buffer.

Returns Err if there was an error locating or reading the object. Returns Ok<None> if there was no such object.

impl Db[src]

Initialization

pub fn at(objects_directory: impl Into<PathBuf>) -> Db[src]

Initialize the Db with the objects_directory containing the hexadecimal first byte subdirectories, which in turn contain all loose objects.

In a git repository, this would be .git/objects.

Trait Implementations

impl Write for Db[src]

type Error = Error

The error type used for all trait methods. Read more

fn write_buf(
    &self,
    kind: Kind,
    from: &[u8],
    hash: Kind
) -> Result<ObjectId, Self::Error>
[src]

Write the given buffer in from to disk in one syscall at best.

This will cost at least 4 IO operations.

fn write_stream(
    &self,
    kind: Kind,
    size: u64,
    from: impl Read,
    hash: Kind
) -> Result<ObjectId, Self::Error>
[src]

Write the given stream in from to disk with at least one syscall.

This will cost at least 4 IO operations.

Auto Trait Implementations

impl RefUnwindSafe for Db

impl Send for Db

impl Sync for Db

impl Unpin for Db

impl UnwindSafe for Db

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> TryConv for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,