2025-10-13 00:55:11 -07:00
|
|
|
use crate::context::SproutContext;
|
2025-11-03 02:04:21 -05:00
|
|
|
use alloc::rc::Rc;
|
|
|
|
|
use alloc::string::String;
|
2025-10-13 00:55:11 -07:00
|
|
|
use anyhow::{Result, bail};
|
2025-11-02 23:28:31 -05:00
|
|
|
use edera_sprout_config::extractors::ExtractorDeclaration;
|
2025-10-13 00:55:11 -07:00
|
|
|
|
2025-10-19 23:03:28 -07:00
|
|
|
/// The filesystem device match extractor.
|
2025-10-13 01:02:51 -07:00
|
|
|
pub mod filesystem_device_match;
|
2025-10-13 00:55:11 -07:00
|
|
|
|
2025-10-19 23:03:28 -07:00
|
|
|
/// Extracts the value using the specified `extractor` under the provided `context`.
|
|
|
|
|
/// The extractor must return a value, and if a value cannot be determined, an error
|
|
|
|
|
/// should be returned.
|
2025-10-13 00:55:11 -07:00
|
|
|
pub fn extract(context: Rc<SproutContext>, extractor: &ExtractorDeclaration) -> Result<String> {
|
2025-10-13 01:02:51 -07:00
|
|
|
if let Some(filesystem) = &extractor.filesystem_device_match {
|
|
|
|
|
filesystem_device_match::extract(context, filesystem)
|
2025-10-13 00:55:11 -07:00
|
|
|
} else {
|
|
|
|
|
bail!("unknown extractor configuration");
|
|
|
|
|
}
|
|
|
|
|
}
|