Struct git2::PackBuilder

source ·
pub struct PackBuilder<'repo> { /* private fields */ }
Expand description

A builder for creating a packfile

Implementations§

source§

impl<'repo> PackBuilder<'repo>

source

pub fn insert_object( &mut self, id: Oid, name: Option<&str> ) -> Result<(), Error>

Insert a single object. For an optimal pack it’s mandatory to insert objects in recency order, commits followed by trees and blobs.

source

pub fn insert_tree(&mut self, id: Oid) -> Result<(), Error>

Insert a root tree object. This will add the tree as well as all referenced trees and blobs.

source

pub fn insert_commit(&mut self, id: Oid) -> Result<(), Error>

Insert a commit object. This will add a commit as well as the completed referenced tree.

source

pub fn insert_walk(&mut self, walk: &mut Revwalk<'_>) -> Result<(), Error>

Insert objects as given by the walk. Those commits and all objects they reference will be inserted into the packbuilder.

source

pub fn insert_recursive( &mut self, id: Oid, name: Option<&str> ) -> Result<(), Error>

Recursively insert an object and its referenced objects. Insert the object as well as any object it references.

source

pub fn write_buf(&mut self, buf: &mut Buf) -> Result<(), Error>

Write the contents of the packfile to an in-memory buffer. The contents of the buffer will become a valid packfile, even though there will be no attached index.

source

pub fn foreach<F>(&mut self, cb: F) -> Result<(), Error>
where F: FnMut(&[u8]) -> bool,

Create the new pack and pass each object to the callback.

source

pub fn set_progress_callback<F>(&mut self, progress: F) -> Result<(), Error>
where F: FnMut(PackBuilderStage, u32, u32) -> bool + 'repo,

progress will be called with progress information during pack building. Be aware that this is called inline with pack building operations, so performance may be affected.

There can only be one progress callback attached, this will replace any existing one. See unset_progress_callback to remove the current progress callback without attaching a new one.

source

pub fn unset_progress_callback(&mut self) -> Result<(), Error>

Remove the current progress callback. See set_progress_callback to set the progress callback.

source

pub fn set_threads(&mut self, threads: u32) -> u32

Set the number of threads to be used.

Returns the number of threads to be used.

source

pub fn object_count(&self) -> usize

Get the total number of objects the packbuilder will write out.

source

pub fn written(&self) -> usize

Get the number of objects the packbuilder has already written out.

source

pub fn hash(&self) -> Option<Oid>

👎Deprecated: use name() to retrieve the filename

Get the packfile’s hash. A packfile’s name is derived from the sorted hashing of all object names. This is only correct after the packfile has been written.

source

pub fn name(&self) -> Option<&str>

Get the unique name for the resulting packfile.

The packfile’s name is derived from the packfile’s content. This is only correct after the packfile has been written.

Returns None if the packfile has not been written or if the name is not valid utf-8.

source

pub fn name_bytes(&self) -> Option<&[u8]>

Get the unique name for the resulting packfile, in bytes.

The packfile’s name is derived from the packfile’s content. This is only correct after the packfile has been written.

Trait Implementations§

source§

impl<'repo> Drop for PackBuilder<'repo>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'repo> !RefUnwindSafe for PackBuilder<'repo>

§

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

§

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

§

impl<'repo> Unpin for PackBuilder<'repo>

§

impl<'repo> !UnwindSafe for PackBuilder<'repo>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.