Crate libpijul_compat

Source
Expand description

This crate contains the core API to access Pijul repositories.

The key object is a Repository, on which Txn (immutable transactions) and MutTxn (mutable transactions) can be started, to perform a variety of operations.

Another important object is a Patch, which encodes two different pieces of information:

  • Information about deleted and inserted lines between two versions of a file.

  • Information about file moves, additions and deletions.

The standard layout of a repository is defined in module fs_representation, and mainly consists of a directory called .pijul at the root of the repository, containing:

  • a directory called pristine, containing a Sanakirja database storing most of the repository information.

  • a directory called patches, actually containing the patches, where each patch is a gzipped compression of the bincode encoding of the patch::Patch type.

At the moment, users of this library, such as the Pijul command-line tool, may use other files in the .pijul directory, such as user preferences, or information about remote branches and repositories.

Re-exports§

pub use patch::Patch;
pub use patch::PatchHeader;

Modules§

apply
fs_representation
Layout of a repository (files in .pijul) on the disk. This module exports both high-level functions that require no knowledge of the repository, and lower-level constants documented on pijul.org/documentation/repository, used for instance for downloading files from remote repositories.
graph
The data structure of the in-memory version of Pijul’s main datastructure, used to edit and organise it (for instance before a record or before outputting a file).
patch
Definition of patches, and a number of methods.

Structs§

Branch
The representation of a branch. The “application number” of a patch on a branch is the state of the application counter at the time the patch has been applied to that branch.
Edge
The target half of an edge in the repository graph.
EdgeFlags
Possible flags of edges.
Error
The Error type.
FileId
FileMetadata
File metadata, essentially flags to indicate permissions and nature of a file tracked by Pijul.
GenericTxn
Common type for both mutable transactions (MutTxn) and immutable transaction (Txn). All of Txn’s methods are also MutTxn’s methods.
Inode
A unique identifier for files or directories in the actual file system, to map “files from the graph” to real files.
Key
A node in the repository graph, made of a patch internal identifier, and a line identifier in that patch.
LineId
An index for file chunks within a patch.
OwnedFileId
PatchId
An internal patch identifier, less random than external patch identifiers, but more stable in time, and much smaller.
Prefixes
RecordState
Repository
A repository. All operations on repositories must be done via transactions.
SmallStr
A borrowed version of SmallStr.
SmallString
A string of length at most 255, with a more compact on-disk encoding.

Enums§

ErrorKind
The kind of an error.
FileStatus
Hash
The external hash of patches.
HashRef
A borrowed version of Hash.
InodeUpdate
An account of the files that have been added, moved or deleted, as returned by record, and used by apply (when applying a patch created locally) to update the trees and inodes databases.
Value
Iterator over parts of a value. On values of size at most 4096 bytes, the iterator will run exactly once. On larger values, it returns all parts of the value, in order.

Constants§

DEFAULT_BRANCH
The default name of a branch, for users who start working before choosing branch names (or like the default name, “master”).
ROOT_INODE
The Inode representing the root of the repository (on the actual file system).
ROOT_KEY
The node at the root of the repository graph.

Traits§

ResultExt
Additional methods for Result, for easy interaction with this crate.
ToPrefixes
Transaction
Trait for operations common to mutable and immutable transactions.

Functions§

apply_resize
Apply a number of patches, guessing the new repository size. If this fails, the repository size is guaranteed to have been increased by at least some pages, and it is safe to call this function again.
apply_resize_no_output
Apply a number of patches, guessing the new repository size. If this fails, the repository size is guaranteed to have been increased by at least some pages, and it is safe to call this function again.
apply_resize_patches
A version of apply_resize with the patches list already loaded.
apply_resize_patches_no_output
unrecord_no_resize
Open the repository, and unrecord the patch, without increasing the size. If this fails, the repository file is guaranteed to have been increased by increase bytes.

Type Aliases§

ApplyTimestamp
The type of patch application numbers.
MutTxn
A mutable transaction on a repository.
Result
Convenient wrapper around std::Result.
Txn
An immutable transaction on a repository.