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, for_loops_over_fallibles)]
10#![allow(unexpected_cfgs)]
11
12//! # dag
13//!
14//! Building blocks for the commit graph used by source control.
15
16mod bsearch;
17pub mod config;
18pub mod dag;
19pub mod default_impl;
20mod delegate;
21pub mod errors;
22mod fmt;
23pub mod iddag;
24pub mod iddagstore;
25pub mod idmap;
26mod idset;
27mod integrity;
28pub(crate) mod lifecycle;
29pub mod ops;
30pub mod protocol;
31#[cfg(any(test, feature = "render"))]
32pub mod render;
33pub mod segment;
34pub mod set;
35pub(crate) mod types_ext;
36pub mod utils;
37mod verlink;
38mod vertex_options;
39
40#[cfg(any(test, feature = "indexedlog-backend"))]
41pub use dag::Dag;
42pub use dag::DagBuilder;
43pub use dag_types::clone;
44pub use dag_types::id;
45pub use dag_types::CloneData;
46pub use dag_types::Group;
47pub use dag_types::Id;
48pub use dag_types::Location;
49pub use dag_types::Vertex;
50pub use iddag::FirstAncestorConstraint;
51pub use iddag::IdDag;
52pub use iddag::IdDagAlgorithm;
53pub use iddagstore::IdDagStore;
54#[cfg(any(test, feature = "indexedlog-backend"))]
55pub use idmap::IdMap;
56pub use idset::IdList;
57pub use idset::IdSet;
58pub use idset::OrderedSpan;
59pub use ops::DagAlgorithm;
60pub use segment::FlatSegment;
61pub use segment::IdSegment;
62pub use segment::PreparedFlatSegments;
63pub use set::Set;
64pub use verlink::VerLink;
65pub use vertex_options::VertexListWithOptions;
66pub use vertex_options::VertexOptions;
67
68pub type Level = u8;
69pub type MemIdDag = IdDag<iddagstore::MemStore>;
70#[cfg(any(test, feature = "indexedlog-backend"))]
71pub type OnDiskIdDag = IdDag<iddagstore::IndexedLogStore>;
72
73// Short aliases for main public types.
74pub type IdSetIter<T> = idset::IdSetIter<T>;
75pub type IdSpan = idset::Span;
76pub use dag::MemDag;
77#[cfg(feature = "indexedlog-backend")]
78pub use iddagstore::indexedlog_store::describe_indexedlog_entry;
79pub use set::NameIter as SetIter;
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!();