diff options
Diffstat (limited to 'embassy-boot/boot/src/partition.rs')
| -rw-r--r-- | embassy-boot/boot/src/partition.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/embassy-boot/boot/src/partition.rs b/embassy-boot/boot/src/partition.rs new file mode 100644 index 000000000..46f80a23c --- /dev/null +++ b/embassy-boot/boot/src/partition.rs | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | /// A region in flash used by the bootloader. | ||
| 2 | #[derive(Copy, Clone, Debug)] | ||
| 3 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 4 | pub struct Partition { | ||
| 5 | /// Start of the flash region. | ||
| 6 | pub from: usize, | ||
| 7 | /// End of the flash region. | ||
| 8 | pub to: usize, | ||
| 9 | } | ||
| 10 | |||
| 11 | impl Partition { | ||
| 12 | /// Create a new partition with the provided range | ||
| 13 | pub const fn new(from: usize, to: usize) -> Self { | ||
| 14 | Self { from, to } | ||
| 15 | } | ||
| 16 | |||
| 17 | /// Return the length of the partition | ||
| 18 | #[allow(clippy::len_without_is_empty)] | ||
| 19 | pub const fn len(&self) -> usize { | ||
| 20 | self.to - self.from | ||
| 21 | } | ||
| 22 | } | ||
