Trait miette::Source [−][src]
pub trait Source: Debug + Send + Sync {
fn read_span<'a>(
&'a self,
span: &SourceSpan
) -> Result<Box<dyn SpanContents + 'a>, MietteError>;
fn name(&self) -> Option<String> { ... }
}
Expand description
Represents a readable source of some sort.
This trait is able to support simple Source types like Strings, as well
as more involved types like indexes into centralized SourceMap
-like types,
file handles, and even network streams.
If you can read it, you can source it, and it’s not necessary to read the whole thing–meaning you should be able to support Sources which are gigabytes or larger in size.
Required methods
fn read_span<'a>(
&'a self,
span: &SourceSpan
) -> Result<Box<dyn SpanContents + 'a>, MietteError>
fn read_span<'a>(
&'a self,
span: &SourceSpan
) -> Result<Box<dyn SpanContents + 'a>, MietteError>
Read the bytes for a specific span from this Source.
Provided methods
Implementations on Foreign Types
fn read_span<'a>(
&'a self,
span: &SourceSpan
) -> Result<Box<dyn SpanContents + 'a>, MietteError>
Makes src: &'static str
or struct S<'a> { src: &'a str }
usable.