Trait Backend

Source
pub trait Backend:
    Send
    + Sync
    + Debug {
Show 23 methods // Required methods fn as_any(&self) -> &dyn Any; fn name(&self) -> &str; fn commit_id_length(&self) -> usize; fn change_id_length(&self) -> usize; fn root_commit_id(&self) -> &CommitId; fn root_change_id(&self) -> &ChangeId; fn empty_tree_id(&self) -> &TreeId; fn concurrency(&self) -> usize; fn read_file<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 RepoPath, id: &'life2 FileId, ) -> Pin<Box<dyn Future<Output = BackendResult<Pin<Box<dyn AsyncRead>>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn write_file<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 RepoPath, contents: &'life2 mut (dyn AsyncRead + Send + Unpin), ) -> Pin<Box<dyn Future<Output = BackendResult<FileId>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn read_symlink<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 RepoPath, id: &'life2 SymlinkId, ) -> Pin<Box<dyn Future<Output = BackendResult<String>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn write_symlink<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 RepoPath, target: &'life2 str, ) -> Pin<Box<dyn Future<Output = BackendResult<SymlinkId>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn read_copy<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 CopyId, ) -> Pin<Box<dyn Future<Output = BackendResult<CopyHistory>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn write_copy<'life0, 'life1, 'async_trait>( &'life0 self, copy: &'life1 CopyHistory, ) -> Pin<Box<dyn Future<Output = BackendResult<CopyId>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_related_copies<'life0, 'life1, 'async_trait>( &'life0 self, copy_id: &'life1 CopyId, ) -> Pin<Box<dyn Future<Output = BackendResult<Vec<CopyHistory>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn read_tree<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 RepoPath, id: &'life2 TreeId, ) -> Pin<Box<dyn Future<Output = BackendResult<Tree>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn write_tree<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 RepoPath, contents: &'life2 Tree, ) -> Pin<Box<dyn Future<Output = BackendResult<TreeId>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn read_conflict( &self, path: &RepoPath, id: &ConflictId, ) -> BackendResult<Conflict>; fn write_conflict( &self, path: &RepoPath, contents: &Conflict, ) -> BackendResult<ConflictId>; fn read_commit<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 CommitId, ) -> Pin<Box<dyn Future<Output = BackendResult<Commit>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn write_commit<'life0, 'life1, 'async_trait>( &'life0 self, contents: Commit, sign_with: Option<&'life1 mut SigningFn<'_>>, ) -> Pin<Box<dyn Future<Output = BackendResult<(CommitId, Commit)>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_copy_records( &self, paths: Option<&[RepoPathBuf]>, root: &CommitId, head: &CommitId, ) -> BackendResult<BoxStream<'_, BackendResult<CopyRecord>>>; fn gc(&self, index: &dyn Index, keep_newer: SystemTime) -> BackendResult<()>;
}
Expand description

Defines the interface for commit backends.

Required Methods§

Source

fn as_any(&self) -> &dyn Any

Source

fn name(&self) -> &str

A unique name that identifies this backend. Written to .jj/repo/store/backend when the repo is created.

Source

fn commit_id_length(&self) -> usize

The length of commit IDs in bytes.

Source

fn change_id_length(&self) -> usize

The length of change IDs in bytes.

Source

fn root_commit_id(&self) -> &CommitId

Source

fn root_change_id(&self) -> &ChangeId

Source

fn empty_tree_id(&self) -> &TreeId

Source

fn concurrency(&self) -> usize

An estimate of how many concurrent requests this backend handles well. A local backend like the Git backend (at until it supports partial clones) may want to set this to 1. A cloud-backed backend may want to set it to 100 or so.

It is not guaranteed that at most this number of concurrent requests are sent.

Source

fn read_file<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 RepoPath, id: &'life2 FileId, ) -> Pin<Box<dyn Future<Output = BackendResult<Pin<Box<dyn AsyncRead>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source

fn write_file<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 RepoPath, contents: &'life2 mut (dyn AsyncRead + Send + Unpin), ) -> Pin<Box<dyn Future<Output = BackendResult<FileId>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source

fn read_copy<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 CopyId, ) -> Pin<Box<dyn Future<Output = BackendResult<CopyHistory>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Read the specified CopyHistory object.

Backends that don’t support copy tracking may return BackendError::Unsupported.

Source

fn write_copy<'life0, 'life1, 'async_trait>( &'life0 self, copy: &'life1 CopyHistory, ) -> Pin<Box<dyn Future<Output = BackendResult<CopyId>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Write the CopyHistory object and return its ID.

Backends that don’t support copy tracking may return BackendError::Unsupported.

Find all copy histories that are related to the specified one. This is defined as those that are ancestors of the given specified one, plus their descendants. Children must be returned before parents.

It is valid (but wasteful) to include other copy histories, such as siblings, or even completely unrelated copy histories.

Backends that don’t support copy tracking may return BackendError::Unsupported.

Source

fn read_tree<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 RepoPath, id: &'life2 TreeId, ) -> Pin<Box<dyn Future<Output = BackendResult<Tree>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source

fn write_tree<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 RepoPath, contents: &'life2 Tree, ) -> Pin<Box<dyn Future<Output = BackendResult<TreeId>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source

fn read_conflict( &self, path: &RepoPath, id: &ConflictId, ) -> BackendResult<Conflict>

Source

fn write_conflict( &self, path: &RepoPath, contents: &Conflict, ) -> BackendResult<ConflictId>

Source

fn read_commit<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 CommitId, ) -> Pin<Box<dyn Future<Output = BackendResult<Commit>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn write_commit<'life0, 'life1, 'async_trait>( &'life0 self, contents: Commit, sign_with: Option<&'life1 mut SigningFn<'_>>, ) -> Pin<Box<dyn Future<Output = BackendResult<(CommitId, Commit)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Writes a commit and returns its ID and the commit itself. The commit should contain the data that was actually written, which may differ from the data passed in. For example, the backend may change the committer name to an authenticated user’s name, or the backend’s timestamps may have less precision than the millisecond precision in Commit.

The sign_with parameter could contain a function to cryptographically sign some binary representation of the commit. If the backend supports it, it could call it and store the result in an implementation specific fashion, and both read_commit and the return of write_commit should read it back as the secure_sig field.

Source

fn get_copy_records( &self, paths: Option<&[RepoPathBuf]>, root: &CommitId, head: &CommitId, ) -> BackendResult<BoxStream<'_, BackendResult<CopyRecord>>>

Get copy records for the dag range root..head. If paths is None include all paths, otherwise restrict to only paths.

The exact order these are returned is unspecified, but it is guaranteed to be reverse-topological. That is, for any two copy records with different commit ids A and B, if A is an ancestor of B, A is streamed after B.

Streaming by design to better support large backends which may have very large single-file histories. This also allows more iterative algorithms like blame/annotate to short-circuit after a point without wasting unnecessary resources.

Source

fn gc(&self, index: &dyn Index, keep_newer: SystemTime) -> BackendResult<()>

Perform garbage collection.

All commits found in the index won’t be removed. In addition to that, objects created after keep_newer will be preserved. This mitigates a risk of deleting new commits created concurrently by another process.

Implementors§