Trait Compiler

Source
pub trait Compiler:
    Send
    + Sync
    + Clone {
    type Input: CompilerInput<Settings = Self::Settings>;
    type CompilationError: CompilationError;
    type ParsedSource: ParsedSource;
    type Settings: CompilerSettings;

    const FILE_EXTENSIONS: &'static [&'static str];

    // Required methods
    fn compile(
        &self,
        input: Self::Input,
    ) -> Result<(Self::Input, CompilerOutput<Self::CompilationError>)>;
    fn version(&self) -> &Version;

    // Provided methods
    fn with_base_path(self, _base_path: PathBuf) -> Self { ... }
    fn with_allowed_paths(self, _allowed_paths: BTreeSet<PathBuf>) -> Self { ... }
    fn with_include_paths(self, _include_paths: BTreeSet<PathBuf>) -> Self { ... }
}
Expand description

The main compiler abstraction trait. Currently mostly represents a wrapper around compiler binary aware of the version and able to compile given input into CompilerOutput including artifacts and errors.

Required Associated Constants§

Source

const FILE_EXTENSIONS: &'static [&'static str]

Extensions of source files recognized by the compiler.

Required Associated Types§

Source

type Input: CompilerInput<Settings = Self::Settings>

Input type for the compiler. Contains settings and sources to be compiled.

Source

type CompilationError: CompilationError

Error type returned by the compiler.

Source

type ParsedSource: ParsedSource

Source parser used for resolving imports and version requirements.

Source

type Settings: CompilerSettings

Compiler settings.

Required Methods§

Source

fn compile( &self, input: Self::Input, ) -> Result<(Self::Input, CompilerOutput<Self::CompilationError>)>

Main entrypoint for the compiler. Compiles given input into CompilerOutput. Takes ownership over the input and returns back version with potential modifications made to it. Returned input is always the one which was seen by the binary.

Source

fn version(&self) -> &Version

Returns the version of the compiler.

Provided Methods§

Source

fn with_base_path(self, _base_path: PathBuf) -> Self

Builder method to set the base path for the compiler. Primarily used by solc implementation to se –base-path.

Source

fn with_allowed_paths(self, _allowed_paths: BTreeSet<PathBuf>) -> Self

Builder method to set the allowed paths for the compiler. Primarily used by solc implementation to set –allow-paths.

Source

fn with_include_paths(self, _include_paths: BTreeSet<PathBuf>) -> Self

Builder method to set the include paths for the compiler. Primarily used by solc implementation to set –include-paths.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§