pub struct SourceManager { /* private fields */ }Expand description
A manager for sources, which stores sources and provides methods to insert and retrieve them.
Implementations§
Source§impl SourceManager
impl SourceManager
Sourcepub fn new(interner: ThreadedInterner) -> Self
pub fn new(interner: ThreadedInterner) -> Self
Sourcepub fn insert_path(
&self,
name: String,
path: PathBuf,
user_defined: bool,
) -> SourceIdentifier
pub fn insert_path( &self, name: String, path: PathBuf, user_defined: bool, ) -> SourceIdentifier
Sourcepub fn insert_content(
&mut self,
name: String,
content: String,
user_defined: bool,
) -> SourceIdentifier
pub fn insert_content( &mut self, name: String, content: String, user_defined: bool, ) -> SourceIdentifier
Sourcepub fn contains(&self, source_id: &SourceIdentifier) -> bool
pub fn contains(&self, source_id: &SourceIdentifier) -> bool
Sourcepub fn source_ids(&self) -> impl Iterator<Item = SourceIdentifier> + '_
pub fn source_ids(&self) -> impl Iterator<Item = SourceIdentifier> + '_
Retrieve an iterator over all source identifiers in the manager.
Sourcepub fn user_defined_source_ids(
&self,
) -> impl Iterator<Item = SourceIdentifier> + '_
pub fn user_defined_source_ids( &self, ) -> impl Iterator<Item = SourceIdentifier> + '_
Retrieve an iterator over all user-defined source identifiers in the manager.
Sourcepub fn external_source_ids(&self) -> impl Iterator<Item = SourceIdentifier> + '_
pub fn external_source_ids(&self) -> impl Iterator<Item = SourceIdentifier> + '_
Retrieve an iterator over all external source identifiers in the manager.
Sourcepub fn load(&self, source_id: SourceIdentifier) -> Result<Source, SourceError>
pub fn load(&self, source_id: SourceIdentifier) -> Result<Source, SourceError>
pub fn write( &self, source_id: SourceIdentifier, content: String, ) -> Result<(), SourceError>
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
Source§impl<'a> Files<'a> for SourceManager
impl<'a> Files<'a> for SourceManager
Source§type FileId = SourceIdentifier
type FileId = SourceIdentifier
A unique identifier for files in the file provider. This will be used
for rendering
diagnostic::Labels in the corresponding source files.Source§fn name(&'a self, file_id: SourceIdentifier) -> Result<&'a str, Error>
fn name(&'a self, file_id: SourceIdentifier) -> Result<&'a str, Error>
The user-facing name of a file.
Source§fn source(&'a self, file_id: SourceIdentifier) -> Result<&'a str, Error>
fn source(&'a self, file_id: SourceIdentifier) -> Result<&'a str, Error>
The source code of a file.
Source§fn line_index(
&self,
file_id: SourceIdentifier,
byte_index: usize,
) -> Result<usize, Error>
fn line_index( &self, file_id: SourceIdentifier, byte_index: usize, ) -> Result<usize, Error>
The index of the line at the given byte index.
If the byte index is past the end of the file, returns the maximum line index in the file.
This means that this function only fails if the file is not present. Read more
Source§fn line_range(
&self,
file_id: SourceIdentifier,
line_index: usize,
) -> Result<Range<usize>, Error>
fn line_range( &self, file_id: SourceIdentifier, line_index: usize, ) -> Result<Range<usize>, Error>
The byte range of line in the source of the file.
Source§fn line_number(
&'a self,
id: Self::FileId,
line_index: usize,
) -> Result<usize, Error>
fn line_number( &'a self, id: Self::FileId, line_index: usize, ) -> Result<usize, Error>
The user-facing line number at the given line index.
It is not necessarily checked that the specified line index
is actually in the file. Read more
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