pub trait Reporter: 'static + Debug {
// Provided methods
fn on_compiler_spawn(
&self,
_compiler_name: &str,
_version: &Version,
_dirty_files: &[PathBuf],
) { ... }
fn on_compiler_success(
&self,
_compiler_name: &str,
_version: &Version,
_duration: &Duration,
) { ... }
fn on_solc_installation_start(&self, _version: &Version) { ... }
fn on_solc_installation_success(&self, _version: &Version) { ... }
fn on_solc_installation_error(&self, _version: &Version, _error: &str) { ... }
fn on_unresolved_imports(
&self,
_imports: &[(&Path, &Path)],
_remappings: &[Remapping],
) { ... }
unsafe fn downcast_raw(&self, id: TypeId) -> Option<NonNull<()>> { ... }
}
Expand description
Trait representing the functions required to emit information about various steps in the compiler pipeline.
This trait provides a series of callbacks that are invoked at certain parts of the
crate::Project::compile()
process.
Implementers of this trait can use these callbacks to emit additional information, for example
print custom messages to stdout
.
A Reporter
is entirely passive and only listens to incoming “events”.
Provided Methods§
Sourcefn on_compiler_spawn(
&self,
_compiler_name: &str,
_version: &Version,
_dirty_files: &[PathBuf],
)
fn on_compiler_spawn( &self, _compiler_name: &str, _version: &Version, _dirty_files: &[PathBuf], )
Callback invoked right before Compiler::compile is called
This contains the Compiler its Version and all files that triggered the compile job. The dirty files are only provided to give a better feedback what was actually compiled.
Sourcefn on_compiler_success(
&self,
_compiler_name: &str,
_version: &Version,
_duration: &Duration,
)
fn on_compiler_success( &self, _compiler_name: &str, _version: &Version, _duration: &Duration, )
Invoked with the CompilerOutput
if Compiler::compile()
was successful
Sourcefn on_solc_installation_start(&self, _version: &Version)
fn on_solc_installation_start(&self, _version: &Version)
Invoked before a new compiler version is installed
Sourcefn on_solc_installation_success(&self, _version: &Version)
fn on_solc_installation_success(&self, _version: &Version)
Invoked after a new compiler version was successfully installed
Sourcefn on_solc_installation_error(&self, _version: &Version, _error: &str)
fn on_solc_installation_error(&self, _version: &Version, _error: &str)
Invoked after a compiler installation failed
Sourcefn on_unresolved_imports(
&self,
_imports: &[(&Path, &Path)],
_remappings: &[Remapping],
)
fn on_unresolved_imports( &self, _imports: &[(&Path, &Path)], _remappings: &[Remapping], )
Invoked if imports couldn’t be resolved with the given remappings, where imports
is the
list of all import paths and the file they occurred in: (import stmt, file)
Sourceunsafe fn downcast_raw(&self, id: TypeId) -> Option<NonNull<()>>
unsafe fn downcast_raw(&self, id: TypeId) -> Option<NonNull<()>>
If self
is the same type as the provided TypeId
, returns an untyped
NonNull
pointer to that type. Otherwise, returns None
.
If you wish to downcast a Reporter
, it is strongly advised to use
the safe API provided by downcast_ref instead.
This API is required for downcast_raw
to be a trait method; a method
signature like downcast_ref (with a generic type parameter) is not
object-safe, and thus cannot be a trait method for Reporter
. This
means that if we only exposed downcast_ref, Reporter
implementations could not override the downcasting behavior
§Safety
The downcast_ref method expects that the pointer returned by
downcast_raw
points to a valid instance of the type
with the provided TypeId
. Failure to ensure this will result in
undefined behaviour, so implementing downcast_raw
is unsafe.