mirror of
https://github.com/edera-dev/sprout.git
synced 2026-11-04 22:02:20 +00:00
feat(bls): boot counting (#107)
* feat(bls): parse and render boot counters * feat(bls): sort entries with no boot tries left last * feat(boot): strip boot counters from bls entry ids * feat(boot): consume bls boot counter tries before booting * fix(boot): never default to a bad boot counter entry while a good one exists
This commit is contained in:
5 files changed
+398
-7
No files matched your search
@@ -1,3 +1,4 @@
|
||||
use crate::boot_counter::BootCounterTarget;
|
||||
use crate::context::SproutContext;
|
||||
use alloc::rc::Rc;
|
||||
use alloc::string::{String, ToString};
|
||||
@@ -14,6 +15,7 @@ pub struct BootableEntry {
|
||||
default: bool,
|
||||
pin_name: bool,
|
||||
sort_key: Option<String>,
|
||||
boot_counter: Option<BootCounterTarget>,
|
||||
}
|
||||
|
||||
impl BootableEntry {
|
||||
@@ -32,6 +34,7 @@ impl BootableEntry {
|
||||
default: false,
|
||||
pin_name: false,
|
||||
sort_key: None,
|
||||
boot_counter: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +103,23 @@ impl BootableEntry {
|
||||
self.pin_name = true;
|
||||
}
|
||||
|
||||
/// Record where the boot counter of this entry is stored.
|
||||
pub fn set_boot_counter(&mut self, target: BootCounterTarget) {
|
||||
self.boot_counter = Some(target);
|
||||
}
|
||||
|
||||
/// Fetch where the boot counter of this entry is stored, if it has one.
|
||||
pub fn boot_counter(&self) -> Option<&BootCounterTarget> {
|
||||
self.boot_counter.as_ref()
|
||||
}
|
||||
|
||||
/// Fetch whether the entry has a boot counter with no tries left.
|
||||
pub fn is_bad(&self) -> bool {
|
||||
self.boot_counter
|
||||
.as_ref()
|
||||
.is_some_and(|target| target.counter.is_bad())
|
||||
}
|
||||
|
||||
/// Prepend the name of the entry with `prefix`.
|
||||
pub fn prepend_name_prefix(&mut self, prefix: &str) {
|
||||
self.name.insert_str(0, prefix);
|
||||
|
||||
Reference in new issue
Block a user