pub struct FsModuleLoader { /* private fields */ }
Expand description
The loader is used to manage the process of creating an in-memory model from file-system resources.
A Module Loader is therefore responsible for:
- finding the resource that contains a module definition,
- parsing the source into an in-memory representation,
- caching the loaded module, and it’s source, for future use.
Implementations§
Source§impl FsModuleLoader
impl FsModuleLoader
pub fn with_resolver(self, resolver: FsModuleResolver) -> Self
pub fn with_reporter(self, reporter: Box<dyn Reporter>) -> Self
Sourcepub fn load_from_file(
&mut self,
file: PathBuf,
cache: &mut impl ModuleStore,
recursive: bool,
) -> Result<Identifier, Error>
pub fn load_from_file( &mut self, file: PathBuf, cache: &mut impl ModuleStore, recursive: bool, ) -> Result<Identifier, Error>
Load a module from the source in file
.
Sourcepub fn load_from_reader(
&mut self,
reader: &mut dyn Read,
cache: &mut impl ModuleStore,
recursive: bool,
) -> Result<Identifier, Error>
pub fn load_from_reader( &mut self, reader: &mut dyn Read, cache: &mut impl ModuleStore, recursive: bool, ) -> Result<Identifier, Error>
Load a module reading the source from reader
.
Trait Implementations§
Source§impl Debug for FsModuleLoader
impl Debug for FsModuleLoader
Source§impl Default for FsModuleLoader
impl Default for FsModuleLoader
Source§impl ModuleLoader for FsModuleLoader
impl ModuleLoader for FsModuleLoader
Source§fn load(
&mut self,
name: &Identifier,
from: Option<FileId>,
cache: &mut impl ModuleStore,
recursive: bool,
) -> Result<Identifier, Error>
fn load( &mut self, name: &Identifier, from: Option<FileId>, cache: &mut impl ModuleStore, recursive: bool, ) -> Result<Identifier, Error>
Resolve
name
into a resource identifier (URL) and parse into memory. The loader will check
the store
first to see if the module is already loaded, and will add the module into the
store after parsing. The value of recursive
tells the loader whether to also load
the module’s dependencies as well.Source§fn resolver(&self) -> &impl ModuleResolver
fn resolver(&self) -> &impl ModuleResolver
Returns the instance of
ModuleResolver
used by this loader.fn get_file_id(&self, name: &Identifier) -> Option<FileId>
fn get_source(&self, file_id: FileId) -> Option<Source>
fn report(&self, diagnostic: &Diagnostic) -> Result<(), Error>
fn reporter_done( &self, top_module_name: Option<String>, ) -> Result<ReportCounters, Error>
fn set_severity_filter(&mut self, filter: SeverityFilter)
fn get_source_by_name(&self, name: &Identifier) -> Option<Source>
fn has_source(&self, file_id: usize) -> bool
Auto Trait Implementations§
impl Freeze for FsModuleLoader
impl !RefUnwindSafe for FsModuleLoader
impl !Send for FsModuleLoader
impl !Sync for FsModuleLoader
impl Unpin for FsModuleLoader
impl !UnwindSafe for FsModuleLoader
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