Skip to main content

ProjectSourceProvider

Trait ProjectSourceProvider 

Source
pub trait ProjectSourceProvider {
    // Required methods
    fn file_type(&self) -> &'static str;
    fn provide_sources(
        &self,
        context: &TargetAssemblyContext<'_>,
    ) -> Result<ProjectSourceInputs, Report>;
    fn provide_source_provenance(
        &self,
        context: &TargetAssemblyContext<'_>,
    ) -> Result<ProjectSourceProvenanceInputs, Report>;
}
Expand description

This trait provides source file inputs for a Miden Assembly project, regardless of the source language it was derived from.

For Miden Assembly source projects this is straightforward, see MasmSourceProvider.

For languages other than MASM, which require a compilation step to produce Miden Assembly AST from the source language prior to assembly, this trait provides the necessary hooks so that the project assembler can request compilation of a project in source form on-demand. Implementors are given all available information needed to compile to MASM, and are expected to return requested artifacts to the project assembler.

Source providers are registered by the file type (i.e. file extension used by the source file) with the assembler when it is created. Only one source provider per-file-type is allowed.

Required Methods§

Source

fn file_type(&self) -> &'static str

Returns the file extension this provider should be registered as handling, e.g. rs

Source

fn provide_sources( &self, context: &TargetAssemblyContext<'_>, ) -> Result<ProjectSourceInputs, Report>

Called to request the compiled/parsed Miden Assembly AST corresponding to the current target being assembled.

Source

fn provide_source_provenance( &self, context: &TargetAssemblyContext<'_>, ) -> Result<ProjectSourceProvenanceInputs, Report>

Called to request the source files that are inputs to assembly of the current target, so that source provenance hash for the target can be computed.

It is expected that all source files that contribute to the build be included in the set of source inputs returned, otherwise package identity for the assembled target will be incomplete, and another instance of the same package may be used from the cache if the source provenance appears unchanged, even when the artifacts produced would be different.

For MASM packages, the above is already guaranteed - but for compilation of packages in other languages, such as Rust, the toolchain invoking the assembler must ensure that all build inputs are accounted for. Note that you do not need to include the sources of your Miden dependencies, and non-Miden dependencies can be accounted for by hashing a dependency lock file if present (e.g. Cargo.toml).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§