mirror of
https://github.com/edera-dev/sprout.git
synced 2026-02-04 16:40:17 +00:00
feat(boot): introduce sort keys, which are sorted in reverse order, to make boot order more configurable (#55)
This commit is contained in:
@@ -12,6 +12,7 @@ pub struct BootableEntry {
|
||||
declaration: EntryDeclaration,
|
||||
default: bool,
|
||||
pin_name: bool,
|
||||
sort_key: Option<String>,
|
||||
}
|
||||
|
||||
impl BootableEntry {
|
||||
@@ -29,6 +30,7 @@ impl BootableEntry {
|
||||
declaration,
|
||||
default: false,
|
||||
pin_name: false,
|
||||
sort_key: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +109,22 @@ impl BootableEntry {
|
||||
self.name == needle || self.title == needle
|
||||
}
|
||||
|
||||
/// Set the sort key of the entry. This is used to sort entries via version comparison.
|
||||
pub fn set_sort_key(&mut self, sort_key: String) {
|
||||
self.sort_key = Some(sort_key);
|
||||
}
|
||||
|
||||
/// Retrieve a reference to the sort key of the entry. If one is not specified, we will use the
|
||||
/// name of the entry.
|
||||
pub fn sort_key(&self) -> &str {
|
||||
// Use the sort key specified in the bootable entry, or use the declaration sort key,
|
||||
// or use the name of the entry.
|
||||
self.sort_key
|
||||
.as_deref()
|
||||
.or(self.declaration.sort_key.as_deref())
|
||||
.unwrap_or(&self.name)
|
||||
}
|
||||
|
||||
/// Find an entry by `needle` inside the entry iterator `haystack`.
|
||||
/// This will search for an entry by name, title, or index.
|
||||
pub fn find<'a>(
|
||||
|
||||
Reference in New Issue
Block a user