Struct codespan::FileMap
[−]
[src]
pub struct FileMap { /* fields omitted */ }
Some source code
Methods
impl FileMap
[src]
pub fn new(name: FileName, src: String) -> FileMap
[src]
Construct a new, standalone filemap.
This can be useful for tests that consist of a single source file. Production code should however
use CodeMap::add_filemap
or CodeMap::add_filemap_from_disk
instead.
pub fn name(&self) -> &FileName
[src]
The name of the file that the source came from
pub fn src(&self) -> &str
[src]
The underlying source code
pub fn span(&self) -> ByteSpan
[src]
The span of the source in the CodeMap
pub fn offset(
&self,
line: LineIndex,
column: ColumnIndex
) -> Result<ByteOffset, LocationError>
[src]
&self,
line: LineIndex,
column: ColumnIndex
) -> Result<ByteOffset, LocationError>
pub fn byte_index(
&self,
line: LineIndex,
column: ColumnIndex
) -> Result<ByteIndex, LocationError>
[src]
&self,
line: LineIndex,
column: ColumnIndex
) -> Result<ByteIndex, LocationError>
pub fn line_offset(
&self,
index: LineIndex
) -> Result<ByteOffset, LineIndexError>
[src]
&self,
index: LineIndex
) -> Result<ByteOffset, LineIndexError>
Returns the byte offset to the start of line
pub fn line_byte_index(
&self,
index: LineIndex
) -> Result<ByteIndex, LineIndexError>
[src]
&self,
index: LineIndex
) -> Result<ByteIndex, LineIndexError>
Returns the byte index of the start of line
pub fn line_span(&self, line: LineIndex) -> Result<ByteSpan, LineIndexError>
[src]
Returns the byte offset to the start of line
pub fn location(
&self,
index: ByteIndex
) -> Result<(LineIndex, ColumnIndex), ByteIndexError>
[src]
&self,
index: ByteIndex
) -> Result<(LineIndex, ColumnIndex), ByteIndexError>
Returns the line and column location of byte
pub fn find_line(&self, index: ByteIndex) -> Result<LineIndex, ByteIndexError>
[src]
Returns the line index that the byte index points to
pub fn src_slice(&self, span: ByteSpan) -> Result<&str, SpanError>
[src]
Get the corresponding source string for a span
Returns Err
if the span is outside the bounds of the file