Trait Compiler

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

Source

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

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

Source

type CompilationError: CompilationError

Error type returned by the compiler.

Source

type CompilerContract: CompilerContract

Output data for each contract

Source

type ParsedSource: ParsedSource<Language = Self::Language>

Source parser used for resolving imports and version requirements.

Source

type Settings: CompilerSettings

Compiler settings.

Source

type Language: Language

Enum of languages supported by the compiler.

Required Methods§

Source

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.

Source

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.

Implementations on Foreign Types§

Source§

impl<'a, T: 'a + Compiler + ?Sized> Compiler for &'a T
where &'a T: Send + Sync + Clone,

Source§

impl<T: Compiler + ?Sized> Compiler for Box<T>
where Box<T>: Send + Sync + Clone,

Source§

impl<T: Compiler + ?Sized> Compiler for Arc<T>
where Arc<T>: Send + Sync + Clone,

Implementors§