dag/
lib.rs

1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#![allow(dead_code)]
9#![allow(clippy::iter_nth_zero, clippy::for_loops_over_fallibles)]
10
11//! # dag
12//!
13//! Building blocks for the commit graph used by source control.
14
15mod bsearch;
16mod default_impl;
17mod delegate;
18pub mod errors;
19mod fmt;
20pub mod iddag;
21pub mod iddagstore;
22pub mod idmap;
23mod integrity;
24pub mod namedag;
25pub mod nameset;
26pub mod ops;
27pub mod protocol;
28#[cfg(any(test, feature = "render"))]
29pub mod render;
30pub mod segment;
31mod spanset;
32pub(crate) mod types_ext;
33pub mod utils;
34mod verlink;
35mod vertex_options;
36
37pub use dag_types::clone;
38pub use dag_types::id;
39pub use dag_types::CloneData;
40pub use dag_types::Group;
41pub use dag_types::Id;
42pub use dag_types::Location;
43pub use dag_types::VertexName;
44pub use iddag::FirstAncestorConstraint;
45pub use iddag::IdDag;
46pub use iddag::IdDagAlgorithm;
47pub use iddagstore::IdDagStore;
48#[cfg(any(test, feature = "indexedlog-backend"))]
49pub use idmap::IdMap;
50#[cfg(any(test, feature = "indexedlog-backend"))]
51pub use namedag::NameDag;
52pub use namedag::NameDagBuilder;
53pub use nameset::NameSet;
54pub use ops::DagAlgorithm;
55pub use segment::FlatSegment;
56pub use segment::IdSegment;
57pub use segment::PreparedFlatSegments;
58pub use verlink::VerLink;
59pub use vertex_options::VertexListWithOptions;
60pub use vertex_options::VertexOptions;
61
62pub type Level = u8;
63pub type InProcessIdDag = IdDag<iddagstore::InProcessStore>;
64#[cfg(any(test, feature = "indexedlog-backend"))]
65pub type OnDiskIdDag = IdDag<iddagstore::IndexedLogStore>;
66
67// Short aliases for main public types.
68#[cfg(any(test, feature = "indexedlog-backend"))]
69pub type Dag = NameDag;
70pub type Set = NameSet;
71pub type IdSet = spanset::SpanSet;
72pub type IdSetIter<T> = spanset::SpanSetIter<T>;
73pub type IdSpan = spanset::Span;
74pub use namedag::MemNameDag as MemDag;
75pub use nameset::NameIter as SetIter;
76pub type Vertex = VertexName;
77
78#[cfg(feature = "indexedlog-backend")]
79pub use iddagstore::indexedlog_store::describe_indexedlog_entry;
80
81#[cfg(any(test, feature = "indexedlog-backend"))]
82pub mod tests;
83
84pub use errors::DagError as Error;
85pub type Result<T> = std::result::Result<T, Error>;
86
87// Re-export
88#[cfg(feature = "indexedlog-backend")]
89pub use indexedlog::Repair;
90pub use nonblocking;
91
92#[macro_export]
93macro_rules! failpoint {
94    ($name:literal) => {
95        ::fail::fail_point!($name, |_| {
96            let msg = format!("failpoint injected by FAILPOINTS: {}", $name);
97            Err($crate::errors::DagError::from(
98                $crate::errors::BackendError::Generic(msg),
99            ))
100        })
101    };
102}
103
104/// Whether running inside a test.
105pub(crate) fn is_testing() -> bool {
106    std::env::var("TESTTMP").is_ok()
107}
108
109#[cfg(test)]
110dev_logger::init!();