Skip to main content

StandardLoader

Struct StandardLoader 

Source
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

Source

pub fn new(config: LoaderConfig) -> Self

Creates a new StandardLoader with the specified configuration

Source

pub fn builder() -> StandardLoaderBuilder

Creates a new StandardLoader with a builder pattern

Source

pub fn stats(&self) -> &LoadStats

Gets the current loading statistics

Source

pub fn clear_cache(&mut self)

Clears the file cache to free memory

Source

pub fn cache_size(&self) -> usize

Gets the number of cached files

Source

pub fn add_module<R>( &mut self, name: &str, code: &mut R, filename: Option<String>, ) -> Result<&mut Self, Error>
where R: Read + Seek,

Add a module with the given name to this loader with enhanced error handling

Source

pub fn import<P>(&mut self, path: P) -> Result<&mut Self, Error>
where P: AsRef<Path>,

Add a single file to this loader as a new module with validation

Source

pub fn add_file<P>(&mut self, path: P) -> Result<&mut Self, Error>
where P: AsRef<Path>,

Add a single file to this loader and merge it into the main module

Source

pub fn import_dir<P>(&mut self, path: P) -> Result<&mut Self, Error>
where P: AsRef<Path>,

Add a directory to this loader and import all files as individual modules

Source

pub fn add_dir<P>(&mut self, path: P) -> Result<&mut Self, Error>
where P: AsRef<Path>,

Add a directory to this loader and merge all files into the main module

Source

pub fn main<P>( &mut self, name: &str, search_paths: Vec<P>, ) -> Result<&mut Self, Error>
where P: AsRef<Path>,

Load the main module with auto-discovery in search paths

Source

pub fn module_names(&self) -> Vec<&String>

Gets all module names currently loaded

Source

pub fn get_module(&self, name: &str) -> Option<&Statement>

Gets a specific module by name

Source

pub fn has_module(&self, name: &str) -> bool

Checks if a module exists

Source

pub fn remove_module(&mut self, name: &str) -> Option<Statement>

Removes a module by name

Trait Implementations§

Source§

impl Default for StandardLoader

Source§

fn default() -> Self

Create a new loader with the default configuration

Source§

impl Loader for StandardLoader

Source§

fn is_resolution_enabled(&self) -> bool

Checks if macro resolution is enabled for this loader Read more
Source§

fn skip_macro_resolution(&mut self) -> Result<&mut Self, Error>

Disables macro resolution for this loader Read more
Source§

fn read(&self) -> Result<Statement, Error>

Reads all BarkML configuration files according to the loader’s configuration and returns the resulting module statement Read more
Source§

fn load(&self) -> Result<Statement, Error>

Loads everything into a module statement and resolves macros if enabled Read more
Source§

fn validate(&self) -> Result<(), Error>

Validates the loaded content without fully processing it Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.