pub trait SourceContainer: Sync + Send {
// Required methods
fn load_source(
&self,
encoding: Option<&'static Encoding>,
) -> Result<SourceCode, String>;
fn get_location(&self) -> Option<&Path>;
// Provided methods
fn get_type(&self) -> SourceType { ... }
fn get_location_str(&self) -> &'static str { ... }
}Expand description
SourceContainers offer source-code to be compiled via the load_source function. Furthermore it offers a location-String used when reporting diagnostics.
Required Methods§
Sourcefn load_source(
&self,
encoding: Option<&'static Encoding>,
) -> Result<SourceCode, String>
fn load_source( &self, encoding: Option<&'static Encoding>, ) -> Result<SourceCode, String>
loads and returns the SourceEntry that contains the SourceCode and the path it was loaded from
Sourcefn get_location(&self) -> Option<&Path>
fn get_location(&self) -> Option<&Path>
returns the location of this source-container. Used when reporting diagnostics.
Provided Methods§
Sourcefn get_type(&self) -> SourceType
fn get_type(&self) -> SourceType
Returns the SourceType for the current container,
by default everything is Text unless it has the extension for a known binary/object
Sourcefn get_location_str(&self) -> &'static str
fn get_location_str(&self) -> &'static str
Returns a staticly available location for this source
Implementors§
impl SourceContainer for SourceCode
tests can provide a SourceCode directly