pub struct FSProvider { /* private fields */ }Expand description
provider that loads declerations from the file system.
this provider syncronously loads decleration files from the file system, and caches them for future use.
this provider works only in a specifed root directory, and loads files of any extension.
it can fails safely when loading.
§example
let provider = FSProvider::new("/path/to/decls").unwrap();
// cache common files
provider.load_file("commons.stomd").unwrap();
// loads other.stomd, commons.stomd is cached
parse(
"import \"commons.stomd\" import \"other.stomd\" ... ",
&ParseOptions::default(), &provider
).unwrap();
// fails in loading not_found.stomd
assert!(parse("import \"not_found.stomd\" ... ", &ParseOptions::default(), &provider).is_err() == true);Implementations§
Source§impl FSProvider
impl FSProvider
Sourcepub fn new(root: impl Into<PathBuf>) -> Result<Self>
pub fn new(root: impl Into<PathBuf>) -> Result<Self>
creates a FSProvider working on a given root directory with default options.
Sourcepub fn with_options(
root: impl Into<PathBuf>,
parse_options: ParseOptions,
) -> Result<Self>
pub fn with_options( root: impl Into<PathBuf>, parse_options: ParseOptions, ) -> Result<Self>
creates a FSProvider working on a given root directory with given options.
Trait Implementations§
Source§impl Debug for FSProvider
impl Debug for FSProvider
Source§impl DeclProvider for FSProvider
impl DeclProvider for FSProvider
Auto Trait Implementations§
impl !Freeze for FSProvider
impl !RefUnwindSafe for FSProvider
impl Send for FSProvider
impl !Sync for FSProvider
impl Unpin for FSProvider
impl UnwindSafe for FSProvider
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