pub trait Compiler:
Send
+ Sync
+ Clone {
type Input: CompilerInput<Settings = Self::Settings, Language = Self::Language>;
type CompilationError: CompilationError;
type CompilerContract: CompilerContract;
type ParsedSource: ParsedSource<Language = Self::Language>;
type Settings: CompilerSettings;
type Language: Language;
// Required methods
fn compile(
&self,
input: &Self::Input,
) -> Result<CompilerOutput<Self::CompilationError, Self::CompilerContract>>;
fn available_versions(
&self,
language: &Self::Language,
) -> Vec<CompilerVersion>;
}
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 Types§
Sourcetype Input: CompilerInput<Settings = Self::Settings, Language = Self::Language>
type Input: CompilerInput<Settings = Self::Settings, Language = Self::Language>
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 CompilerContract: CompilerContract
type CompilerContract: CompilerContract
Output data for each contract
Sourcetype ParsedSource: ParsedSource<Language = Self::Language>
type ParsedSource: ParsedSource<Language = Self::Language>
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<CompilerOutput<Self::CompilationError, Self::CompilerContract>>
fn compile( &self, input: &Self::Input, ) -> Result<CompilerOutput<Self::CompilationError, Self::CompilerContract>>
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.
Sourcefn available_versions(&self, language: &Self::Language) -> Vec<CompilerVersion>
fn available_versions(&self, language: &Self::Language) -> Vec<CompilerVersion>
Returns all versions available locally and remotely. Should return versions with stripped metadata.
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.