pub struct StandardLoader { /* private fields */ }Expand description
Standard loader for BarkML files with enhanced capabilities
This loader supports multiple methodologies for reading and combining BarkML files:
- Loading individual files with validation
- Loading directories of files with filtering
- Merging multiple files into a single module with conflict resolution
- Importing files as separate modules with namespace management
- Auto-discovering files in search paths with caching
- Performance monitoring and statistics collection
- Robust error handling and recovery
The loader can be configured through LoaderConfig to handle various scenarios and provides detailed statistics about the loading process.
Implementations§
Source§impl StandardLoader
impl StandardLoader
Sourcepub fn new(config: LoaderConfig) -> Self
pub fn new(config: LoaderConfig) -> Self
Creates a new StandardLoader with the specified configuration
Sourcepub fn builder() -> StandardLoaderBuilder
pub fn builder() -> StandardLoaderBuilder
Creates a new StandardLoader with a builder pattern
Sourcepub fn clear_cache(&mut self)
pub fn clear_cache(&mut self)
Clears the file cache to free memory
Sourcepub fn cache_size(&self) -> usize
pub fn cache_size(&self) -> usize
Gets the number of cached files
Sourcepub fn add_module<R>(
&mut self,
name: &str,
code: &mut R,
filename: Option<String>,
) -> Result<&mut Self, Error>
pub fn add_module<R>( &mut self, name: &str, code: &mut R, filename: Option<String>, ) -> Result<&mut Self, Error>
Add a module with the given name to this loader with enhanced error handling
Sourcepub fn import<P>(&mut self, path: P) -> Result<&mut Self, Error>
pub fn import<P>(&mut self, path: P) -> Result<&mut Self, Error>
Add a single file to this loader as a new module with validation
Sourcepub fn add_file<P>(&mut self, path: P) -> Result<&mut Self, Error>
pub fn add_file<P>(&mut self, path: P) -> Result<&mut Self, Error>
Add a single file to this loader and merge it into the main module
Sourcepub fn import_dir<P>(&mut self, path: P) -> Result<&mut Self, Error>
pub fn import_dir<P>(&mut self, path: P) -> Result<&mut Self, Error>
Add a directory to this loader and import all files as individual modules
Sourcepub fn add_dir<P>(&mut self, path: P) -> Result<&mut Self, Error>
pub fn add_dir<P>(&mut self, path: P) -> Result<&mut Self, Error>
Add a directory to this loader and merge all files into the main module
Sourcepub fn main<P>(
&mut self,
name: &str,
search_paths: Vec<P>,
) -> Result<&mut Self, Error>
pub fn main<P>( &mut self, name: &str, search_paths: Vec<P>, ) -> Result<&mut Self, Error>
Load the main module with auto-discovery in search paths
Sourcepub fn module_names(&self) -> Vec<&String>
pub fn module_names(&self) -> Vec<&String>
Gets all module names currently loaded
Sourcepub fn get_module(&self, name: &str) -> Option<&Statement>
pub fn get_module(&self, name: &str) -> Option<&Statement>
Gets a specific module by name
Sourcepub fn has_module(&self, name: &str) -> bool
pub fn has_module(&self, name: &str) -> bool
Checks if a module exists
Sourcepub fn remove_module(&mut self, name: &str) -> Option<Statement>
pub fn remove_module(&mut self, name: &str) -> Option<Statement>
Removes a module by name