mirror of
https://github.com/edera-dev/sprout.git
synced 2025-12-19 10:30:17 +00:00
chore(context): add documentation to the stamping algorithm
This commit is contained in:
@@ -12,6 +12,8 @@ use std::time::Duration;
|
||||
use uefi::boot::ScopedProtocol;
|
||||
use uefi::proto::console::gop::GraphicsOutput;
|
||||
|
||||
/// We set the default splash time to zero, as this makes it so any logging shows up
|
||||
/// on top of the splash and does not hold up the boot process.
|
||||
const DEFAULT_SPLASH_TIME: u32 = 0;
|
||||
|
||||
/// The configuration of the splash action.
|
||||
|
||||
@@ -219,6 +219,14 @@ impl SproutContext {
|
||||
|
||||
/// Stamps the `text` value with the specified `values` map. The returned value indicates
|
||||
/// whether the `text` has been changed and the value that was stamped and changed.
|
||||
///
|
||||
/// Stamping works like this:
|
||||
/// - Start with the input text.
|
||||
/// - Sort all the keys in reverse length order (longest keys first)
|
||||
/// - For each key, if the key is not empty, replace $KEY in the text.
|
||||
/// - Each follow-up iteration acts upon the last iterations result.
|
||||
/// - We keep track if the text changes during the replacement.
|
||||
/// - We return both whether the text changed during any iteration and the final result.
|
||||
fn stamp_values(values: &BTreeMap<String, String>, text: impl AsRef<str>) -> (bool, String) {
|
||||
let mut result = text.as_ref().to_string();
|
||||
let mut did_change = false;
|
||||
|
||||
Reference in New Issue
Block a user