pub trait World {
// Required methods
fn entry_point(&self) -> FileId;
fn source(&self, file_id: FileId) -> FileResult<Source>;
fn library(&self) -> &Library;
fn write(&self, f: &dyn Fn(&mut dyn Write) -> Result<()>) -> Result<()>;
fn read(&self, f: &dyn Fn(&mut dyn Read) -> Result<()>) -> Result<()>;
// Provided methods
fn name(&self, id: FileId) -> String { ... }
fn related_source(&self, span: Span) -> Option<Source> { ... }
}
Required Methods§
Sourcefn entry_point(&self) -> FileId
fn entry_point(&self) -> FileId
The entrypoint file of the program to execute
fn source(&self, file_id: FileId) -> FileResult<Source>
fn library(&self) -> &Library
fn write(&self, f: &dyn Fn(&mut dyn Write) -> Result<()>) -> Result<()>
fn read(&self, f: &dyn Fn(&mut dyn Read) -> Result<()>) -> Result<()>
Provided Methods§
Trait Implementations§
Source§impl<'a> Files<'a> for &dyn World
impl<'a> Files<'a> for &dyn World
Source§type FileId = FileId
type FileId = FileId
A unique identifier for files in the file provider. This will be used
for rendering
diagnostic::Label
s in the corresponding source files.Source§fn name(&'a self, id: Self::FileId) -> Result<Self::Name, Error>
fn name(&'a self, id: Self::FileId) -> Result<Self::Name, Error>
The user-facing name of a file.
Source§fn source(&'a self, id: Self::FileId) -> Result<Self::Source, Error>
fn source(&'a self, id: Self::FileId) -> Result<Self::Source, Error>
The source code of a file.
Source§fn line_index(
&'a self,
id: Self::FileId,
byte_index: usize,
) -> Result<usize, Error>
fn line_index( &'a self, id: Self::FileId, 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(
&'a self,
id: Self::FileId,
line_index: usize,
) -> Result<Range<usize>, Error>
fn line_range( &'a self, id: Self::FileId, 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