Expand description
A bundle of pack data and the corresponding pack index
Fields
pack: FileThe pack file corresponding to index
index: FileThe index file corresponding to pack
Implementations
sourceimpl Bundle
impl Bundle
Initialization
sourcepub fn at(path: impl AsRef<Path>, object_hash: Kind) -> Result<Self, Error>
pub fn at(path: impl AsRef<Path>, object_hash: Kind) -> Result<Self, Error>
Create a Bundle from path, which is either a pack file (*.pack) or an index file (*.idx).
The corresponding complementary file is expected to be present.
The object_hash is a way to read (and write) the same file format with different hashes, as the hash kind
isn’t stored within the file format itself.
sourceimpl Bundle
impl Bundle
sourceimpl Bundle
impl Bundle
sourcepub fn write_to_directory<P>(
pack: impl BufRead,
directory: Option<impl AsRef<Path>>,
progress: P,
should_interrupt: &AtomicBool,
thin_pack_base_object_lookup_fn: Option<Box<dyn for<'a> FnMut(ObjectId, &'a mut Vec<u8>) -> Option<Data<'a>>>>,
options: Options
) -> Result<Outcome, Error> where
P: Progress,
pub fn write_to_directory<P>(
pack: impl BufRead,
directory: Option<impl AsRef<Path>>,
progress: P,
should_interrupt: &AtomicBool,
thin_pack_base_object_lookup_fn: Option<Box<dyn for<'a> FnMut(ObjectId, &'a mut Vec<u8>) -> Option<Data<'a>>>>,
options: Options
) -> Result<Outcome, Error> where
P: Progress,
Given a pack data stream, write it along with a generated index into the directory if Some or discard all output if None.
In the latter case, the functionality provided here is more akind of pack data stream validation.
progressprovides detailed progress information which can be discarded with [git_features::progress::Discard].should_interruptis checked regularly and when true, the whole operation will stop.thin_pack_base_object_lookup_fnIf set, we expect to see a thin-pack with objects that reference their base object by object id which is expected to exist in the object database the bundle is contained within.optionsfurther configure how the task is performed.
Note
- the resulting pack may be empty, that is, contains zero objects in some situations. This is a valid reply by a server and should
be accounted for.
- Empty packs always have the same name and not handling this case will result in at most one superfluous pack.
sourcepub fn write_to_directory_eagerly(
pack: impl Read + Send + 'static,
pack_size: Option<u64>,
directory: Option<impl AsRef<Path>>,
progress: impl Progress,
should_interrupt: &'static AtomicBool,
thin_pack_base_object_lookup_fn: Option<Box<dyn for<'a> FnMut(ObjectId, &'a mut Vec<u8>) -> Option<Data<'a>> + Send + 'static>>,
options: Options
) -> Result<Outcome, Error>
pub fn write_to_directory_eagerly(
pack: impl Read + Send + 'static,
pack_size: Option<u64>,
directory: Option<impl AsRef<Path>>,
progress: impl Progress,
should_interrupt: &'static AtomicBool,
thin_pack_base_object_lookup_fn: Option<Box<dyn for<'a> FnMut(ObjectId, &'a mut Vec<u8>) -> Option<Data<'a>> + Send + 'static>>,
options: Options
) -> Result<Outcome, Error>
Equivalent to write_to_directory() but offloads reading of the pack into its own thread, hence the Send + 'static' bounds.
Note
As it sends portions of the input to a thread it requires the ’static lifetime for the interrupt flags. This can only be satisfied by a static AtomicBool which is only suitable for programs that only run one of these operations at a time or don’t mind that all of them abort when the flag is set.
sourceimpl Bundle
impl Bundle
sourcepub fn verify_integrity<C, P, F>(
&self,
progress: P,
should_interrupt: &AtomicBool,
options: Options<F>
) -> Result<Outcome<P>, Error<Error>> where
P: Progress,
C: DecodeEntry,
F: Fn() -> C + Send + Clone,
pub fn verify_integrity<C, P, F>(
&self,
progress: P,
should_interrupt: &AtomicBool,
options: Options<F>
) -> Result<Outcome<P>, Error<Error>> where
P: Progress,
C: DecodeEntry,
F: Fn() -> C + Send + Clone,
Similar to crate::index::File::verify_integrity() but more convenient to call as the presence of the
pack file is a given.
Auto Trait Implementations
impl RefUnwindSafe for Bundle
impl Send for Bundle
impl Sync for Bundle
impl Unpin for Bundle
impl UnwindSafe for Bundle
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more