ostrya-core
Ostrya [n. a botanical genus within the family Betulaceae, commonly known as ironwood tree] is a pure-Rust, async implementation of the ostree repository system, written from scratch.
The object model, the on-disk format primitives, and the typed config of ostree.
A caller reads and writes the objects of an ostree repository as bytes in
the on-disk format and computes their checksums. The crate also holds the
format rules for loose paths, ref names, and new commits. It re-exports the
GVariant codec of ostrya-gvariant for the metadata of a commit. The
module config reads and edits the keys of a repository config file
through key types, with no repository handle. The crate opens no file, and
it compiles on Linux, macOS, and Windows.
API documentation: https://docs.rs/ostrya-core
Entry points
Checksumis the SHA-256 id of an object.Commitreads and writes a commit object.DirTreeandDirMetaread and write the objects of a directory.FileHeaderis the header of a content object.Xattrsis a sorted set of extended attributes.ObjectTypeandRepoModeselect theloose_pathof an object.DeflateSinkcompresses the payload of an archive-mode content object.KeyFileparses and prints the text of the repositoryconfigfile.config::ConfigViewandconfig::ConfigEditread and edit aKeyFilethrough the key types ofconfig.Refis one ref of a repository: local, remote, or collection.RefPatternchecks and matches one ref pattern with*and**.RefSelectorselects ref names with a list of positive and negative patterns.
Modules
base64: standard base64 for byte strings of any length.config: the typed config. It holds the traits of the groups and the keys, the text form of a value, and the typed reads and edits. It also holds the groups[core]and[ex-integrity], and the value types of the keys of the port that use no item ofostrya.filehdr: the content-object header, its framing, and its checksum.sizes: the packed entries of theostree.sizescommit metadata.varint: the LEB128 varints of the format.
Typed config
Each key of config is a zero-sized type. The type states the group, the
key name, the value type, and the default of the key. The module
config::repo holds the key types of [core], and the module
config::ex_integrity holds the key types of [ex-integrity].
config::ConfigViewreads aKeyFilethrough the key types. It has no override, so the value in effect of a key is the value of the file or the default of the key.config::ConfigEditedits aKeyFilein memory through the key types.config_group!defines a group of a library user and its key types. The name of the group starts withex-.- A library user implements
config::Valuefor each value type of its own. - A typed read and a typed edit give
config::ConfigError.
The ostrya crate re-exports each documented item of config under
ostrya::config, and the macro as ostrya::config_group!. It adds
RepoConfig and the other groups of the port. RepoConfig applies the
overrides of a repository handle and reads the remotes of the remotes
directory.
ostrya reads and writes config with a cap of 1 MiB (1048576 bytes). A
program that links ostrya-core alone reads at most that many bytes before
KeyFile::parse. It does not write a larger document, because the open
of ostrya refuses such a file.
Examples
use ;
// The root directory of a commit: uid 0, gid 0, mode 0755, no xattrs.
let meta = DirMeta ;
let checksum = sha256;
let hex = "446a0ef11b7cc167f3b603e585c7eeeeb675faa412d5ec73f62988eb0b6c5488";
assert_eq!;
let path = loose_path;
assert_eq!;
A library user defines a group, reads the group and a key of [core], and
edits the key file:
use ;
use ;
config_group!
let mut kf = parse?;
let view = new;
assert_eq!;
assert_eq!;
new.?;
assert_eq!;