[][src]Struct codespan::FileMap

pub struct FileMap<S = String> { /* fields omitted */ }

Some source code

Methods

impl<S> FileMap<S> where
    S: AsRef<str>, 
[src]

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]

pub fn byte_index(
    &self,
    line: LineIndex,
    column: ColumnIndex
) -> Result<ByteIndex, LocationError>
[src]

pub fn line_offset(
    &self,
    index: LineIndex
) -> Result<ByteOffset, LineIndexError>
[src]

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]

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]

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

impl<S: Debug> Debug for FileMap<S>[src]

Auto Trait Implementations

impl<S> Send for FileMap<S> where
    S: Send

impl<S> Sync for FileMap<S> where
    S: Sync

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.