Skip to content

Commit 264a7b5

Browse files
committed
factors: Tweak Factor::prepare signature
Signed-off-by: Lann Martin <[email protected]>
1 parent 2a67cf3 commit 264a7b5

File tree

9 files changed

+10
-10
lines changed

9 files changed

+10
-10
lines changed

crates/factor-key-value/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ impl Factor for KeyValueFactor {
102102
}
103103

104104
fn prepare<T: RuntimeFactors>(
105+
&self,
105106
ctx: PrepareContext<Self>,
106107
_builders: &mut InstanceBuilders<T>,
107108
) -> anyhow::Result<InstanceBuilder> {

crates/factor-outbound-http/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ impl Factor for OutboundHttpFactor {
3636
}
3737

3838
fn prepare<T: RuntimeFactors>(
39+
&self,
3940
_ctx: PrepareContext<Self>,
4041
builders: &mut InstanceBuilders<T>,
4142
) -> anyhow::Result<Self::InstanceBuilder> {

crates/factor-outbound-networking/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ impl Factor for OutboundNetworkingFactor {
4949
}
5050

5151
fn prepare<T: RuntimeFactors>(
52+
&self,
5253
ctx: PrepareContext<Self>,
5354
builders: &mut InstanceBuilders<T>,
5455
) -> anyhow::Result<Self::InstanceBuilder> {

crates/factor-variables/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ impl Factor for VariablesFactor {
8181
}
8282

8383
fn prepare<T: RuntimeFactors>(
84+
&self,
8485
ctx: PrepareContext<Self>,
8586
_builders: &mut InstanceBuilders<T>,
8687
) -> anyhow::Result<InstanceState> {

crates/factor-wasi/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ impl Factor for WasiFactor {
7878
}
7979

8080
fn prepare<T: RuntimeFactors>(
81+
&self,
8182
ctx: PrepareContext<Self>,
8283
_builders: &mut InstanceBuilders<T>,
8384
) -> anyhow::Result<InstanceBuilder> {
@@ -92,8 +93,7 @@ impl Factor for WasiFactor {
9293
let mount_ctx = MountFilesContext {
9394
wasi_ctx: &mut wasi_ctx,
9495
};
95-
ctx.factor()
96-
.files_mounter
96+
self.files_mounter
9797
.mount_files(ctx.app_component(), mount_ctx)?;
9898

9999
Ok(InstanceBuilder { wasi_ctx })

crates/factor-wasi/src/preview1.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ impl Factor for WasiPreview1Factor {
2323
}
2424

2525
fn prepare<T: RuntimeFactors>(
26+
&self,
2627
_ctx: spin_factors::PrepareContext<Self>,
2728
_builders: &mut spin_factors::InstanceBuilders<T>,
2829
) -> anyhow::Result<Self::InstanceBuilder> {

crates/factors-derive/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ fn expand_factors(input: &DeriveInput) -> syn::Result<TokenStream> {
121121
#(
122122
builders.#factor_names = Some(
123123
#Factor::prepare::<Self>(
124+
&self.#factor_names,
124125
#factors_path::PrepareContext::new(
125-
&self.#factor_names,
126126
configured_app.app_state::<#factor_types>().unwrap(),
127127
&app_component,
128128
),

crates/factors/src/factor.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub trait Factor: Any + Sized {
3838
/// This method is given access to the app component being instantiated and
3939
/// to any other factors' instance builders that have already been prepared.
4040
fn prepare<T: RuntimeFactors>(
41+
&self,
4142
ctx: PrepareContext<Self>,
4243
_builders: &mut InstanceBuilders<T>,
4344
) -> anyhow::Result<Self::InstanceBuilder>;

crates/factors/src/prepare.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,19 @@ impl<T: SelfInstanceBuilder> FactorInstanceBuilder for T {
3232
/// already-initialized [`FactorInstanceBuilder`]s, allowing for
3333
/// inter-[`Factor`] dependencies.
3434
pub struct PrepareContext<'a, F: Factor> {
35-
pub(crate) factor: &'a F,
3635
pub(crate) app_state: &'a F::AppState,
3736
pub(crate) app_component: &'a AppComponent<'a>,
3837
}
3938

4039
impl<'a, F: Factor> PrepareContext<'a, F> {
4140
#[doc(hidden)]
42-
pub fn new(factor: &'a F, app_state: &'a F::AppState, app_component: &'a AppComponent) -> Self {
41+
pub fn new(app_state: &'a F::AppState, app_component: &'a AppComponent) -> Self {
4342
Self {
44-
factor,
4543
app_state,
4644
app_component,
4745
}
4846
}
4947

50-
pub fn factor(&self) -> &F {
51-
self.factor
52-
}
53-
5448
pub fn app_state(&self) -> &F::AppState {
5549
self.app_state
5650
}

0 commit comments

Comments
 (0)