Skip to main content

Step

Trait Step 

Source
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§

Source

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 successfully
  • Err(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());
Source

fn get_name(&self) -> &str

Returns the name of this step.

§Examples
let step = MyStep { name: "data-processing".to_string() };
assert_eq!(step.get_name(), "data-processing");

Implementors§

Source§

impl Step for TaskletStep<'_>

Source§

impl<I, O> Step for ChunkOrientedStep<'_, I, O>