1mod debug_print;
4mod edit;
5mod frozen;
6mod hot;
7mod internal;
8mod membership;
9mod plain;
10
11use core::cell::BorrowError;
12use core::fmt;
13
14pub(crate) use self::debug_print::DebugPrintSubtreeDescendant;
15pub use self::debug_print::{DebugPrettyPrint, DebugPrintNodeLocal, DebugPrintSubtree};
16pub use self::frozen::FrozenNode;
17pub use self::hot::HotNode;
18use self::internal::NodeCoreLinkWeak;
19pub(crate) use self::internal::{NodeCoreLink, NodeLink};
20pub use self::plain::{Node, NodeWeak};
21
22#[derive(Debug)]
27#[non_exhaustive]
28pub enum HierarchyError {
29 AncestorDescendantLoop,
31 EmptyTree,
35 SiblingsWithoutParent,
37 BorrowNodeData(BorrowError),
39}
40
41impl fmt::Display for HierarchyError {
42 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
43 let msg = match *self {
44 Self::AncestorDescendantLoop => "attempt to make a node its own descendant or ancestor",
45 Self::EmptyTree => "attempt to make a tree empty",
46 Self::SiblingsWithoutParent => "attempt to make a node sibling of the root node",
47 Self::BorrowNodeData(_) => "failed to borrow the data associated to the node",
48 };
49 f.write_str(msg)
50 }
51}
52
53#[cfg(feature = "std")]
54impl std::error::Error for HierarchyError {
55 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
56 match self {
57 Self::BorrowNodeData(e) => Some(e),
58 _ => None,
59 }
60 }
61}