Skip to content

Commit bac388d

Browse files
authored
Merge pull request #2682 from lann/tweak-aot-wording
trigger: Tweak wording of AOT compilation code
2 parents 1effaa2 + ba9ce6b commit bac388d

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

crates/trigger/src/loader.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ use tokio::fs;
1313
use spin_common::{ui::quoted_path, url::parse_file_url};
1414

1515
/// Compilation status of all components of a Spin application
16-
pub enum CompilationStatus {
16+
pub enum AotCompilationStatus {
17+
/// No components are ahead of time (AOT) compiled.
18+
Disabled,
1719
#[cfg(feature = "unsafe-aot-compilation")]
1820
/// All components are componentized and ahead of time (AOT) compiled to cwasm.
19-
AllAotComponents,
20-
/// No components are ahead of time (AOT) compiled.
21-
NoneAot,
21+
Enabled,
2222
}
2323

2424
/// Loader for the Spin runtime
@@ -28,15 +28,15 @@ pub struct TriggerLoader {
2828
/// Set the static assets of the components in the temporary directory as writable.
2929
allow_transient_write: bool,
3030
/// Declares the compilation status of all components of a Spin application.
31-
compilation_status: CompilationStatus,
31+
aot_compilation_status: AotCompilationStatus,
3232
}
3333

3434
impl TriggerLoader {
3535
pub fn new(working_dir: impl Into<PathBuf>, allow_transient_write: bool) -> Self {
3636
Self {
3737
working_dir: working_dir.into(),
3838
allow_transient_write,
39-
compilation_status: CompilationStatus::NoneAot,
39+
aot_compilation_status: AotCompilationStatus::Disabled,
4040
}
4141
}
4242

@@ -69,7 +69,7 @@ impl TriggerLoader {
6969
/// from untrusted sources.**
7070
#[cfg(feature = "unsafe-aot-compilation")]
7171
pub unsafe fn enable_loading_aot_compiled_components(&mut self) {
72-
self.compilation_status = CompilationStatus::AllAotComponents;
72+
self.aot_compilation_status = AotCompilationStatus::Enabled;
7373
}
7474
}
7575

@@ -95,9 +95,9 @@ impl Loader for TriggerLoader {
9595
.as_ref()
9696
.context("LockedComponentSource missing source field")?;
9797
let path = parse_file_url(source)?;
98-
match self.compilation_status {
98+
match self.aot_compilation_status {
9999
#[cfg(feature = "unsafe-aot-compilation")]
100-
CompilationStatus::AllAotComponents => {
100+
AotCompilationStatus::Enabled => {
101101
match engine.detect_precompiled_file(&path)?{
102102
Some(wasmtime::Precompiled::Component) => {
103103
unsafe {
@@ -110,17 +110,17 @@ impl Loader for TriggerLoader {
110110
anyhow::bail!("Spin loader is configured to load only AOT compiled components, but {} is not precompiled", quoted_path(&path))
111111
}
112112
}
113-
},
114-
CompilationStatus::NoneAot => {
113+
}
114+
AotCompilationStatus::Disabled => {
115115
let bytes = fs::read(&path).await.with_context(|| {
116-
format!(
117-
"failed to read component source from disk at path {}",
118-
quoted_path(&path)
119-
)
120-
})?;
121-
let component = spin_componentize::componentize_if_necessary(&bytes)?;
122-
spin_core::Component::new(engine, component.as_ref())
123-
.with_context(|| format!("loading module {}", quoted_path(&path)))
116+
format!(
117+
"failed to read component source from disk at path {}",
118+
quoted_path(&path)
119+
)
120+
})?;
121+
let component = spin_componentize::componentize_if_necessary(&bytes)?;
122+
spin_core::Component::new(engine, component.as_ref())
123+
.with_context(|| format!("loading module {}", quoted_path(&path)))
124124
}
125125
}
126126
}

0 commit comments

Comments
 (0)