Skip to main content

RepositoryFacts

Trait RepositoryFacts 

Source
pub trait RepositoryFacts {
    // Required methods
    fn location(&mut self) -> Result<RepositoryLocation, String>;
    fn index_vs_head(&mut self) -> Result<IndexVsHead, String>;
    fn sequencer_state(&mut self) -> Result<SequencerState, String>;
    fn remote_guess_creates_branch(
        &mut self,
        target: &OsStr,
    ) -> Result<bool, String>;
    fn candidates(
        &mut self,
        request: &CandidateRequest,
    ) -> Result<PreparedCandidates, CandidateError>;
    fn asked_location(&self) -> Option<Result<RepositoryLocation, String>>;
    fn transaction_context(&self) -> GitContext;
}
Expand description

What: The facts a rule may ask for. A trait is a named set of methods a type promises to provide, like a TS interface; &mut self lends the provider for writing, because it remembers answers. Result<T, String> is “a value, or a message saying why Git could not be asked or understood”. Why: Two providers exist: real Git for the executable, a script for tests.

In TS you’d write (pseudocode):

interface RepositoryFacts { location(): Promise<RepositoryLocation>; indexVsHead(): Promise<IndexVsHead>; /* ... */ }

Required Methods§

Source

fn location(&mut self) -> Result<RepositoryLocation, String>

Repository identity, worktree top level and the path below it; asked once.

Source

fn index_vs_head(&mut self) -> Result<IndexVsHead, String>

Whether the index differs from HEAD.

Source

fn sequencer_state(&mut self) -> Result<SequencerState, String>

Whether a merge, cherry-pick or revert awaits its concluding commit.

Source

fn remote_guess_creates_branch( &mut self, target: &OsStr, ) -> Result<bool, String>

Whether git switch <target> or git checkout <target> would create a local branch from the one remote branch of that name.

Source

fn candidates( &mut self, request: &CandidateRequest, ) -> Result<PreparedCandidates, CandidateError>

The candidates a content policy reads for this request, prepared on a private index; a failure carries the candidate layer’s cause.

Source

fn asked_location(&self) -> Option<Result<RepositoryLocation, String>>

The location when it was already asked for, without asking.

Source

fn transaction_context(&self) -> GitContext

Real Git, the child environment and the invocation’s global options, for transaction and recovery work.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<F: RepositoryFacts> RepositoryFacts for &mut F

A borrowed provider answers like the provider it borrows.

Implementors§

Source§

impl RepositoryFacts for GitFacts

What: impl RepositoryFacts for GitFacts provides the interface’s methods for the real-Git provider. Why: Each method is one query whose arguments and reading belong to a pure core.

In TS you’d write (pseudocode):

class GitFacts implements RepositoryFacts { /* ... */ }
Source§

impl<F: RepositoryFacts> RepositoryFacts for PrivateIndexFacts<F>