skill_embed/state.rs
1/// What is already present at a destination.
2///
3/// The name it prints comes from the variant, through [`std::fmt::Display`].
4#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, strum::Display)]
5#[strum(serialize_all = "kebab-case")]
6pub enum State {
7 /// Nothing is installed there yet.
8 Missing,
9 /// The installed copy matches the embedded skill.
10 UpToDate,
11 /// This tool installed it and it is not what the binary would write now.
12 /// The binary carries a newer copy, or a file lost the executable bit it
13 /// was installed with.
14 Outdated,
15 /// This tool installed it and the files were edited afterwards.
16 Modified,
17 /// Something else owns a skill of that name there.
18 Foreign,
19 /// This tool wrote it, it is still byte for byte what was written, and the
20 /// binary no longer carries a skill of that name. An earlier version
21 /// installed it and nothing would reach the directory again.
22 Orphaned,
23}
24
25impl State {
26 /// Reports whether overwriting this state would destroy work that this tool
27 /// did not create.
28 #[must_use]
29 pub const fn needs_force(self) -> bool {
30 matches!(self, Self::Modified | Self::Foreign)
31 }
32}