1/// Identifies a cluster on disk.
2///
3/// A cluster is a consecutive group of blocks. Each cluster has a a numeric ID.
4/// Some numeric IDs are reserved for special purposes.
5#[cfg_attr(feature = "defmt-log", derive(defmt::Format))]
6#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)]
7pub struct ClusterId(pub(crate) u32);
89impl ClusterId {
10/// Magic value indicating an invalid cluster value.
11pub const INVALID: ClusterId = ClusterId(0xFFFF_FFF6);
12/// Magic value indicating a bad cluster.
13pub const BAD: ClusterId = ClusterId(0xFFFF_FFF7);
14/// Magic value indicating a empty cluster.
15pub const EMPTY: ClusterId = ClusterId(0x0000_0000);
16/// Magic value indicating the cluster holding the root directory (which
17 /// doesn't have a number in FAT16 as there's a reserved region).
18pub const ROOT_DIR: ClusterId = ClusterId(0xFFFF_FFFC);
19/// Magic value indicating that the cluster is allocated and is the final cluster for the file
20pub const END_OF_FILE: ClusterId = ClusterId(0xFFFF_FFFF);
21}
2223impl core::ops::Add<u32> for ClusterId {
24type Output = ClusterId;
25fn add(self, rhs: u32) -> ClusterId {
26 ClusterId(self.0 + rhs)
27 }
28}
2930impl core::ops::AddAssign<u32> for ClusterId {
31fn add_assign(&mut self, rhs: u32) {
32self.0 += rhs;
33 }
34}