generate_sample

Function generate_sample 

Source
pub fn generate_sample<T>(
    message_type: &str,
    scenario_name: Option<&str>,
) -> Result<SwiftMessage<T>>
Expand description

Generate a sample SWIFT MT message based on test scenarios (backward compatibility)

This function loads a test scenario configuration for the specified message type and generates a realistic SWIFT message using datafake-rs for dynamic data generation.

§Arguments

  • message_type - The MT message type (e.g., “MT103”, “MT202”)
  • scenario_name - Optional scenario name. If None, uses the default scenario

§Returns

Returns a complete SwiftMessage object with headers and the message body

§Example

// Generate a standard MT103 message
let mt103_msg: SwiftMessage<MT103> = generate_sample("MT103", None).unwrap();
println!("{}", mt103_msg.to_mt_message());

// Generate a specific scenario
let mt103_high_value: SwiftMessage<MT103> = generate_sample("MT103", Some("high_value_payment")).unwrap();