Struct gix_diff::blob::Pipeline

source ·
pub struct Pipeline {
    pub roots: WorktreeRoots,
    pub worktree_filter: Pipeline,
    pub options: Options,
    /* private fields */
}
Available on crate feature blob only.
Expand description

A conversion pipeline to take an object or path from what’s stored in git to what can be diffed, while following the guidance of git-attributes at the respective path to learn if diffing should happen or if the content is considered binary.

There are two different conversion flows, where the target of the flow is a buffer with diffable content:

  • worktree on disk -> text conversion
  • object -> worktree-filters -> text conversion

Fields§

§roots: WorktreeRoots

A way to read data directly from the worktree.

§worktree_filter: Pipeline

A pipeline to convert objects from what’s stored in git to its worktree version.

§options: Options

Options affecting the way we read files.

Implementations§

source§

impl Pipeline

Lifecycle

source

pub fn new( roots: WorktreeRoots, worktree_filter: Pipeline, drivers: Vec<Driver>, options: Options ) -> Self

Create a new instance of a pipeline which produces blobs suitable for diffing. roots allow to read worktree files directly, otherwise worktree_filter is used to transform object database data directly. drivers further configure individual paths. options are used to further configure the way we act..

source§

impl Pipeline

Access

source

pub fn drivers(&self) -> &[Driver]

Return all drivers that this instance was initialized with.

source§

impl Pipeline

Conversion

source

pub fn convert_to_diffable( &mut self, id: &oid, mode: EntryKind, rela_path: &BStr, kind: ResourceKind, attributes: &mut dyn FnMut(&BStr, &mut Outcome), objects: &dyn FindObjectOrHeader, convert: Mode, out: &mut Vec<u8> ) -> Result<Outcome, Error>

Convert the object at id, mode, rela_path and kind, providing access to attributes and objects. The resulting diff-able data is written into out, assuming it’s not too large. The returned Outcome contains information on how to use out, or if it’s filled at all.

attributes must be returning the attributes at rela_path, and objects must be usable if kind is a resource in the object database, i.e. has no worktree root available.

If id is null or the file in question doesn’t exist in the worktree in case a root is present, then out will be left cleared and Outcome::data will be None.

Note that mode is trusted, and we will not re-validate that the entry in the worktree actually is of that mode.

Use convert to control what kind of the resource will be produced.

About Tempfiles

When querying from the object database and a binary and a binary-to-text is set, a temporary file will be created to serve as input for the converter program, containing the worktree-data that exactly as it would be present in the worktree if checked out.

As these files are ultimately named tempfiles, they will be leaked unless the gix_tempfile is configured with a signal handler. If they leak, they would remain in the system’s $TMP directory.

Trait Implementations§

source§

impl Clone for Pipeline

source§

fn clone(&self) -> Pipeline

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.