Struct codespan::FileMap [−][src]
pub struct FileMap<S = String> { /* fields omitted */ }
Some source code
Methods
impl<S> FileMap<S> where
S: AsRef<str>, [src]
impl<S> FileMap<S> where
S: AsRef<str>, pub fn new(name: FileName, src: S) -> FileMap<S>[src]
pub fn new(name: FileName, src: S) -> FileMap<S>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]
pub fn name(&self) -> &FileNameThe name of the file that the source came from
pub fn src(&self) -> &str[src]
pub fn src(&self) -> &strThe underlying source code
pub fn span(&self) -> ByteSpan[src]
pub fn span(&self) -> ByteSpanThe span of the source in the CodeMap
pub fn offset(
&self,
line: LineIndex,
column: ColumnIndex
) -> Result<ByteOffset, LocationError>[src]
pub fn offset(
&self,
line: LineIndex,
column: ColumnIndex
) -> Result<ByteOffset, LocationError>pub fn byte_index(
&self,
line: LineIndex,
column: ColumnIndex
) -> Result<ByteIndex, LocationError>[src]
pub fn byte_index(
&self,
line: LineIndex,
column: ColumnIndex
) -> Result<ByteIndex, LocationError>pub fn line_offset(
&self,
index: LineIndex
) -> Result<ByteOffset, LineIndexError>[src]
pub fn line_offset(
&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]
pub fn line_byte_index(
&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]
pub fn line_span(&self, line: LineIndex) -> Result<ByteSpan, LineIndexError>Returns the byte offset to the start of line
pub fn location(
&self,
index: ByteIndex
) -> Result<(LineIndex, ColumnIndex), ByteIndexError>[src]
pub fn location(
&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]
pub fn find_line(&self, index: ByteIndex) -> Result<LineIndex, ByteIndexError>Returns the line index that the byte index points to
pub fn src_slice(&self, span: ByteSpan) -> Result<&str, SpanError>[src]
pub fn src_slice(&self, span: ByteSpan) -> Result<&str, SpanError>Get the corresponding source string for a span
Returns Err if the span is outside the bounds of the file