[−][src]Struct codespan::FileMap
Some source code
Methods
impl<S> FileMap<S> where
S: AsRef<str>,
[src]
S: AsRef<str>,
pub fn new(name: FileName, src: S) -> FileMap<S>
[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
.
Lines may be delimited with either \n
or \r\n
.
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
.
Lines may be delimited with either \n
or \r\n
.
pub fn line_span(&self, line: LineIndex) -> Result<ByteSpan, LineIndexError>
[src]
Returns the byte offset to the start of line
.
Lines may be delimited with either \n
or \r\n
.
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
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,