miette

Trait SpanContents

source
pub trait SpanContents<'a> {
    // Required methods
    fn data(&self) -> &'a [u8] ;
    fn span(&self) -> &SourceSpan;
    fn line(&self) -> usize;
    fn column(&self) -> usize;
    fn line_count(&self) -> usize;

    // Provided methods
    fn name(&self) -> Option<&str> { ... }
    fn language(&self) -> Option<&str> { ... }
}
Expand description

Contents of a SourceCode covered by SourceSpan.

Includes line and column information to optimize highlight calculations.

Required Methods§

source

fn data(&self) -> &'a [u8]

Reference to the data inside the associated span, in bytes.

source

fn span(&self) -> &SourceSpan

SourceSpan representing the span covered by this SpanContents.

source

fn line(&self) -> usize

The 0-indexed line in the associated SourceCode where the data begins.

source

fn column(&self) -> usize

The 0-indexed column in the associated SourceCode where the data begins, relative to line.

source

fn line_count(&self) -> usize

Total number of lines covered by this SpanContents.

Provided Methods§

source

fn name(&self) -> Option<&str>

An optional (file?) name for the container of this SpanContents.

source

fn language(&self) -> Option<&str>

Optional method. The language name for this source code, if any. This is used to drive syntax highlighting.

Examples: Rust, TOML, C

Implementors§