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