pub trait BootstrapStep<T: DatabaseConnection>: Send + Sync {
// Required methods
fn name(&self) -> &'static str;
fn description(&self) -> &'static str;
fn verify<'life0, 'life1, 'async_trait>(
&'life0 self,
txn: &'life1 T::DatabaseTransaction,
) -> Pin<Box<dyn Future<Output = Result<VerifyDetails, BootstrapError<T::Error>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn run<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
txn: &'life1 T::DatabaseTransaction,
details: &'life2 VerifyDetails,
) -> Pin<Box<dyn Future<Output = Result<Option<StepOutput>, BootstrapError<T::Error>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided methods
fn dependencies(&self) -> Vec<Box<dyn StepFactory<T>>> { ... }
fn requirement(&self) -> Requirement { ... }
fn skip_if_missing(&self) -> bool { ... }
}Expand description
A single bootstrap step that can verify and create seed data.
Steps can depend on other steps, forming a DAG. The runner executes steps in topological order after verifying dependencies are satisfied.
§Example
struct MyStep;
#[async_trait]
impl BootstrapStep for MyStep {
fn name(&self) -> &'static str { "my_step" }
fn description(&self) -> &'static str { "Does something" }
async fn verify(&self, txn: &DatabaseTransaction) -> Result<VerifyDetails, BootstrapError> {
// Check if data exists
Ok(VerifyDetails::new(VerifyResult::Missing))
}
async fn run(&self, txn: &DatabaseTransaction, details: &VerifyDetails) -> Result<Option<StepOutput>, BootstrapError> {
// Create data
Ok(Some(StepOutput::new("My Step Output")
.field("key", "value")
.sensitive()))
}
}Required Methods§
Sourcefn description(&self) -> &'static str
fn description(&self) -> &'static str
Human-readable description of what this step does.
Sourcefn verify<'life0, 'life1, 'async_trait>(
&'life0 self,
txn: &'life1 T::DatabaseTransaction,
) -> Pin<Box<dyn Future<Output = Result<VerifyDetails, BootstrapError<T::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn verify<'life0, 'life1, 'async_trait>(
&'life0 self,
txn: &'life1 T::DatabaseTransaction,
) -> Pin<Box<dyn Future<Output = Result<VerifyDetails, BootstrapError<T::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if the data for this step already exists.
Returns detailed information about each entity’s existence status. This information is passed to run() to avoid redundant queries.
Sourcefn run<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
txn: &'life1 T::DatabaseTransaction,
details: &'life2 VerifyDetails,
) -> Pin<Box<dyn Future<Output = Result<Option<StepOutput>, BootstrapError<T::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn run<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
txn: &'life1 T::DatabaseTransaction,
details: &'life2 VerifyDetails,
) -> Pin<Box<dyn Future<Output = Result<Option<StepOutput>, BootstrapError<T::Error>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Create the data for this step. Called only if verify returns Missing or Partial.
Receives the verification details to avoid redundant queries.
Returns Some(StepOutput) if there are secrets or other information
that should be displayed in the bootstrap summary.
Provided Methods§
Sourcefn dependencies(&self) -> Vec<Box<dyn StepFactory<T>>>
fn dependencies(&self) -> Vec<Box<dyn StepFactory<T>>>
Factories for steps that must run before this one.
If a dependency is not registered in the runner, it will be automatically created using the factory and executed first.
Sourcefn requirement(&self) -> Requirement
fn requirement(&self) -> Requirement
Whether this step’s data is required or optional.
Sourcefn skip_if_missing(&self) -> bool
fn skip_if_missing(&self) -> bool
Whether to skip this step with a warning if data is missing.
When true and verify returns Missing:
- Logs a warning
- Marks step as completed without running
- Does not auto-create the data
When false (default) and verify returns Missing:
- Runs the step to create the data