pub struct SourceManager { /* private fields */ }Expand description
A manager for sources.
Implementations§
Source§impl SourceManager
impl SourceManager
Sourcepub fn new(interner: ThreadedInterner) -> Self
pub fn new(interner: ThreadedInterner) -> Self
Creates a new source manager.
Sourcepub fn insert_path(
&self,
name: impl AsRef<str>,
path: PathBuf,
category: SourceCategory,
) -> SourceIdentifier
pub fn insert_path( &self, name: impl AsRef<str>, path: PathBuf, category: SourceCategory, ) -> SourceIdentifier
Inserts a source with the given name and path.
Sourcepub fn insert_content(
&self,
name: impl AsRef<str>,
content: impl AsRef<str>,
category: SourceCategory,
) -> SourceIdentifier
pub fn insert_content( &self, name: impl AsRef<str>, content: impl AsRef<str>, category: SourceCategory, ) -> SourceIdentifier
Inserts a source with the given name and content.
Sourcepub fn contains(&self, source_id: &SourceIdentifier) -> bool
pub fn contains(&self, source_id: &SourceIdentifier) -> bool
Returns whether the manager contains a source with the given identifier.
Sourcepub fn source_ids(&self) -> impl Iterator<Item = SourceIdentifier> + '_
pub fn source_ids(&self) -> impl Iterator<Item = SourceIdentifier> + '_
Returns an iterator over all source identifiers.
Sourcepub fn source_ids_for_category(
&self,
category: SourceCategory,
) -> impl Iterator<Item = SourceIdentifier> + '_
pub fn source_ids_for_category( &self, category: SourceCategory, ) -> impl Iterator<Item = SourceIdentifier> + '_
Returns an iterator over source identifiers for the given category.
Sourcepub fn source_ids_except_category(
&self,
category: SourceCategory,
) -> impl Iterator<Item = SourceIdentifier> + '_
pub fn source_ids_except_category( &self, category: SourceCategory, ) -> impl Iterator<Item = SourceIdentifier> + '_
Returns an iterator over source identifiers for categories other than the given category.
Sourcepub fn load(&self, source_id: &SourceIdentifier) -> Result<Source, SourceError>
pub fn load(&self, source_id: &SourceIdentifier) -> Result<Source, SourceError>
Loads the source with the given identifier.
If the source content is already loaded, it is returned directly. Otherwise, the file is read from disk, processed, and cached.
Sourcepub fn write(
&self,
source_id: SourceIdentifier,
new_content: impl AsRef<str>,
) -> Result<(), SourceError>
pub fn write( &self, source_id: SourceIdentifier, new_content: impl AsRef<str>, ) -> Result<(), SourceError>
Writes updated content for the source with the given identifier.
Trait Implementations§
Source§impl Clone for SourceManager
impl Clone for SourceManager
Source§fn clone(&self) -> SourceManager
fn clone(&self) -> SourceManager
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SourceManager
impl Debug for SourceManager
impl Send for SourceManager
impl Sync for SourceManager
Auto Trait Implementations§
impl Freeze for SourceManager
impl !RefUnwindSafe for SourceManager
impl Unpin for SourceManager
impl !UnwindSafe for SourceManager
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