pub struct SourceManager { /* private fields */ }Expand description
A manager for sources.
This version replaces DashMap with a single inner structure protected by a
high-performance RwLock (from the parking_lot crate) and uses AHashMap for speed.
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 file 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) -> Vec<SourceIdentifier>
pub fn source_ids(&self) -> Vec<SourceIdentifier>
Returns all source identifiers.
Sourcepub fn source_ids_for_category(
&self,
category: SourceCategory,
) -> Vec<SourceIdentifier>
pub fn source_ids_for_category( &self, category: SourceCategory, ) -> Vec<SourceIdentifier>
Returns source identifiers for the given category.
Sourcepub fn source_ids_except_category(
&self,
category: SourceCategory,
) -> Vec<SourceIdentifier>
pub fn source_ids_except_category( &self, category: SourceCategory, ) -> Vec<SourceIdentifier>
Returns source identifiers for categories other than the given one.
Sourcepub fn load(&self, source_id: &SourceIdentifier) -> Result<Source, SourceError>
pub fn load(&self, source_id: &SourceIdentifier) -> Result<Source, SourceError>
Loads the source for the given identifier.
If the source content is already loaded, it is returned immediately. 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
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more