aboutsummaryrefslogtreecommitdiff
path: root/embassy-boot/boot/src/partition.rs
diff options
context:
space:
mode:
authorRasmus Melchior Jacobsen <[email protected]>2023-03-31 08:05:37 +0200
committerRasmus Melchior Jacobsen <[email protected]>2023-03-31 08:05:37 +0200
commit373760a56b1bad13ebcec19247ee3ee4ae4cb07c (patch)
tree60122df250ce6a777b723b4d3b3fd86e0f7d2f99 /embassy-boot/boot/src/partition.rs
parent5955d813745e409cecadb1f36cca7c3522e8d915 (diff)
Split bootloader implementation into multiple files
Diffstat (limited to 'embassy-boot/boot/src/partition.rs')
-rw-r--r--embassy-boot/boot/src/partition.rs22
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))]
4pub struct Partition {
5 /// Start of the flash region.
6 pub from: usize,
7 /// End of the flash region.
8 pub to: usize,
9}
10
11impl 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}