spire_core/crawler/meta/
depth.rs1use std::fmt;
2
3#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, PartialOrd, Ord)]
7pub struct Depth(u32);
8
9impl Depth {
10 pub const ROOT: Self = Self(0);
12
13 #[must_use]
15 pub const fn new(depth: u32) -> Self {
16 Self(depth)
17 }
18
19 #[must_use]
21 pub const fn get(self) -> u32 {
22 self.0
23 }
24
25 #[must_use]
27 pub const fn child(self) -> Self {
28 Self(self.0.saturating_add(1))
29 }
30}
31
32impl fmt::Display for Depth {
33 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
34 self.0.fmt(f)
35 }
36}