Struct git2::Odb[][src]

pub struct Odb<'repo> { /* fields omitted */ }

A structure to represent a git object database

Implementations

impl<'repo> Odb<'repo>[src]

pub fn new<'a>() -> Result<Odb<'a>, Error>[src]

Creates an object database without any backends.

pub fn reader(
    &self,
    oid: Oid
) -> Result<(OdbReader<'_>, usize, ObjectType), Error>
[src]

Create object database reading stream.

Note that most backends do not support streaming reads because they store their objects as compressed/delta’ed blobs. If the backend does not support streaming reads, use the read method instead.

pub fn writer(
    &self,
    size: usize,
    obj_type: ObjectType
) -> Result<OdbWriter<'_>, Error>
[src]

Create object database writing stream.

The type and final length of the object must be specified when opening the stream. If the backend does not support streaming writes, use the write method instead.

pub fn foreach<C>(&self, callback: C) -> Result<(), Error> where
    C: FnMut(&Oid) -> bool
[src]

Iterate over all objects in the object database.s

pub fn read(&self, oid: Oid) -> Result<OdbObject<'_>, Error>[src]

Read an object from the database.

pub fn read_header(&self, oid: Oid) -> Result<(usize, ObjectType), Error>[src]

Reads the header of an object from the database without reading the full content.

pub fn write(&self, kind: ObjectType, data: &[u8]) -> Result<Oid, Error>[src]

Write an object to the database.

pub fn packwriter(&self) -> Result<OdbPackwriter<'_>, Error>[src]

Create stream for writing a pack file to the ODB

pub fn exists(&self, oid: Oid) -> bool[src]

Checks if the object database has an object.

pub fn exists_prefix(&self, short_oid: Oid, len: usize) -> Result<Oid, Error>[src]

Potentially finds an object that starts with the given prefix.

pub fn refresh(&self) -> Result<(), Error>[src]

Refresh the object database. This should never be needed, and is provided purely for convenience. The object database will automatically refresh when an object is not found when requested.

pub fn add_disk_alternate(&self, path: &str) -> Result<(), Error>[src]

Adds an alternate disk backend to the object database.

pub fn add_new_mempack_backend<'odb>(
    &'odb self,
    priority: i32
) -> Result<Mempack<'odb>, Error>
[src]

Create a new mempack backend, and add it to this odb with the given priority. Higher values give the backend higher precedence. The default loose and pack backends have priorities 1 and 2 respectively (hard-coded in libgit2). A reference to the new mempack backend is returned on success. The lifetime of the backend must be contained within the lifetime of this odb, since deletion of the odb will also result in deletion of the mempack backend.

Here is an example that fails to compile because it tries to hold the mempack reference beyond the odb’s lifetime:

use git2::Odb;
let mempack = {
    let odb = Odb::new().unwrap();
    odb.add_new_mempack_backend(1000).unwrap()
};

Trait Implementations

impl<'repo> Drop for Odb<'repo>[src]

Auto Trait Implementations

impl<'repo> RefUnwindSafe for Odb<'repo>

impl<'repo> !Send for Odb<'repo>

impl<'repo> !Sync for Odb<'repo>

impl<'repo> Unpin for Odb<'repo>

impl<'repo> UnwindSafe for Odb<'repo>

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> From<T> for T[src]

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

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.