Module stdlib

Source
Expand description

Standard library to work on Software Heritage compressed graph in Rust

Structs§

NodeVisit
Stateful BFS (breadth-first search) visit of (a part of) the Software Heritage graph, returning deduplicated node identifiers.

Enums§

FsTree
Recursive representation of a directory tree, ignoring sharing.

Constants§

HEAD_REF_NAMES
Names of references (“branches”) that are considered to be pointing to the HEAD revision in a VCS, by find_head_rev below. Names are tried in order, when attempting to identify the HEAD revision.

Functions§

find_head_rev
Given a graph and a snapshot node in it, return the node id of the revision pointed by the HEAD branch, it it exists.
find_head_rev_by_refs
Same as find_head_rev, but with the ability to configure which branch names correspond to the HEAD revision.
find_latest_snp
Given a graph and an origin node in it, return the node id and timestamp (as a number of seconds since Epoch) of the most recent snapshot of that origin, if it exists.
find_root_dir
Given a node id pointing to a revision or release, returns the node id of the associated topmost (“root”) directory.
fs_ls_tree
Given a graph and a directory node in it (usually, but not necessarily, the root directory of a repository), return a recursive list of the contained files and directories.
fs_resolve_name
Given a graph and a directory node, return the node id of a named directory entry located (not recursively) in that directory, if it exists.
fs_resolve_name_by_id
Same as fs_resolve_name, but using a pre-resolved FilenameId as entry name. Using this function is more efficient in case the same name (e.g., “README.md”) is to be looked up in many directories.
fs_resolve_path
Given a graph and a directory node, return the node id of a directory entry located at a given path within that directory, if it exists.
fs_resolve_path_by_id
Same as fs_resolve_path, but using as path a sequence of pre-resolved FilenameId-s. Using this function is more efficient in case the same path (e.g., “src/main.c”) is to be looked up in many directories.
iter_nodes
Iterate on the nodes of the sub-graph rooted at start, in BFS order.