Trait World

Source
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§

Source

fn entry_point(&self) -> FileId

The entrypoint file of the program to execute

Source

fn source(&self, file_id: FileId) -> FileResult<Source>

Source

fn library(&self) -> &Library

Source

fn write(&self, f: &dyn Fn(&mut dyn Write) -> Result<()>) -> Result<()>

Source

fn read(&self, f: &dyn Fn(&mut dyn Read) -> Result<()>) -> Result<()>

Provided Methods§

Source

fn name(&self, id: FileId) -> String

Source

fn related_source(&self, span: Span) -> Option<Source>

Trait Implementations§

Source§

impl<'a> Files<'a> for &dyn World

Source§

type FileId = FileId

A unique identifier for files in the file provider. This will be used for rendering diagnostic::Labels in the corresponding source files.
Source§

type Name = String

The user-facing name of a file, to be displayed in diagnostics.
Source§

type Source = Source

The source code of a file.
Source§

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>

The source code of a file.
Source§

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>

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>

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
Source§

fn column_number( &'a self, id: Self::FileId, line_index: usize, byte_index: usize, ) -> Result<usize, Error>

The user-facing column number at the given line index and byte index. Read more
Source§

fn location( &'a self, id: Self::FileId, byte_index: usize, ) -> Result<Location, Error>

Convenience method for returning line and column number at the given byte index in the file.

Implementors§