Skip to content

Commit

Permalink
Small change on UniversalEngine for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb committed May 3, 2022
1 parent 6353847 commit d8a7d9f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/universal-artifact/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,26 @@ impl UniversalEngineBuilder {
pub fn new(compiler: Option<Box<dyn Compiler>>, features: Features) -> Self {
UniversalEngineBuilder { compiler, features }
}

/// Gets the compiler associated to this engine.
#[cfg(feature = "compiler")]
pub fn compiler(&self) -> Result<&dyn Compiler, CompileError> {
if self.compiler.is_none() {
return Err(CompileError::Codegen("The UniversalEngine is operating in headless mode, so it can only execute already compiled Modules.".to_string()));
return Err(CompileError::Codegen(
"The UniversalEngine is not compiled in.".to_string(),
));
}
Ok(&**self.compiler.as_ref().unwrap())
}

/// Gets the compiler associated to this engine.
#[cfg(not(feature = "compiler"))]
pub fn compiler(&self) -> Result<&dyn Compiler, CompileError> {
return Err(CompileError::Codegen(
"The UniversalEngine is not compiled in.".to_string(),
));
}

/// Validate the module
#[cfg(feature = "compiler")]
pub fn validate<'data>(&self, data: &'data [u8]) -> Result<(), CompileError> {
Expand Down

0 comments on commit d8a7d9f

Please sign in to comment.