pub trait Step {
// Required methods
fn execute(
&self,
step_execution: &mut StepExecution,
) -> Result<(), BatchError>;
fn get_name(&self) -> &str;
}Expand description
Core trait that defines the contract for step execution.
All step implementations must provide execution logic and a name. The step is responsible for coordinating the processing of data and managing its own lifecycle.
§Examples
use spring_batch_rs::core::step::{Step, StepExecution};
use spring_batch_rs::BatchError;
struct CustomStep {
name: String,
}
impl Step for CustomStep {
fn execute(&self, step_execution: &mut StepExecution) -> Result<(), BatchError> {
// Custom step logic here
Ok(())
}
fn get_name(&self) -> &str {
&self.name
}
}Required Methods§
Sourcefn execute(&self, step_execution: &mut StepExecution) -> Result<(), BatchError>
fn execute(&self, step_execution: &mut StepExecution) -> Result<(), BatchError>
Executes the step.
This method represents the main operation of the step. It coordinates reading items, processing them, and writing them out for chunk-oriented steps, or executes a single task for tasklet steps.
§Parameters
step_execution: Mutable reference to track execution state and metrics
§Returns
Ok(()): The step completed successfullyErr(BatchError): The step failed due to an error
§Examples
use spring_batch_rs::core::step::{Step, StepExecution, StepStatus};
use spring_batch_rs::BatchError;
let step = MyStep { name: "test".to_string() };
let mut execution = StepExecution::new(step.get_name());
let result = step.execute(&mut execution);
assert!(result.is_ok());