Skip to main content

SourceContainer

Trait SourceContainer 

Source
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§

Source

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

Source

fn get_location(&self) -> Option<&Path>

returns the location of this source-container. Used when reporting diagnostics.

Provided Methods§

Source

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

Source

fn get_location_str(&self) -> &'static str

Returns a staticly available location for this source

Implementors§

Source§

impl SourceContainer for SourceCode

tests can provide a SourceCode directly

Source§

impl<T: AsRef<Path> + Sync + Send> SourceContainer for T