From d8a7d9f987468316f2981b5e54118386a23d26e6 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Thu, 21 Apr 2022 16:34:34 +0200 Subject: [PATCH] Small change on UniversalEngine for consistency --- lib/universal-artifact/src/engine.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/universal-artifact/src/engine.rs b/lib/universal-artifact/src/engine.rs index f2225e0ddaf..fe57b3156c8 100644 --- a/lib/universal-artifact/src/engine.rs +++ b/lib/universal-artifact/src/engine.rs @@ -21,15 +21,26 @@ impl UniversalEngineBuilder { pub fn new(compiler: Option>, 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> {