pub struct FileRegistryConfig<T> {
pub extensions: &'static [&'static str],
pub transform: fn(&str) -> Result<T, LoadError>,
}Expand description
Configuration for a file registry.
Specifies which file extensions to recognize and how to transform file content into the target type.
§Example
ⓘ
// For template files (identity transform)
FileRegistryConfig {
extensions: &[".tmpl", ".jinja2", ".j2"],
transform: |content| Ok(content.to_string()),
}
// For stylesheet files (YAML parsing)
FileRegistryConfig {
extensions: &[".yaml", ".yml"],
transform: |content| parse_style_definitions(content),
}Fields§
§extensions: &'static [&'static str]Valid file extensions in priority order (first = highest priority).
When multiple files exist with the same base name but different extensions, the extension appearing earlier in this list wins for extensionless lookups.
transform: fn(&str) -> Result<T, LoadError>Transform function: file content → typed value.
Called when reading a file to convert raw string content into the target type.
Return Err(LoadError::Transform { .. }) for parse failures.
Auto Trait Implementations§
impl<T> Freeze for FileRegistryConfig<T>
impl<T> RefUnwindSafe for FileRegistryConfig<T>
impl<T> Send for FileRegistryConfig<T>
impl<T> Sync for FileRegistryConfig<T>
impl<T> Unpin for FileRegistryConfig<T>
impl<T> UnwindSafe for FileRegistryConfig<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more