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§
Sourceconst FILE_EXTENSIONS: &'static [&'static str]
const FILE_EXTENSIONS: &'static [&'static str]
Extensions of source files recognized by the compiler.
Required Associated Types§
Sourcetype Input: CompilerInput<Settings = Self::Settings>
type Input: CompilerInput<Settings = Self::Settings>
Input type for the compiler. Contains settings and sources to be compiled.
Sourcetype CompilationError: CompilationError
type CompilationError: CompilationError
Error type returned by the compiler.
Sourcetype ParsedSource: ParsedSource
type ParsedSource: ParsedSource
Source parser used for resolving imports and version requirements.
Sourcetype Settings: CompilerSettings
type Settings: CompilerSettings
Compiler settings.
Required Methods§
Sourcefn compile(
&self,
input: Self::Input,
) -> Result<(Self::Input, CompilerOutput<Self::CompilationError>)>
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.
Provided Methods§
Sourcefn with_base_path(self, _base_path: PathBuf) -> Self
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.
Sourcefn with_allowed_paths(self, _allowed_paths: BTreeSet<PathBuf>) -> Self
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.
Sourcefn with_include_paths(self, _include_paths: BTreeSet<PathBuf>) -> Self
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.