pub struct SwiftParser { /* private fields */ }
Expand description
Main parser for SWIFT MT messages
§Purpose
Primary parsing engine that converts raw SWIFT message strings into typed, validated message structures. Handles all aspects of SWIFT message processing including block extraction, header parsing, field parsing, and type-safe message construction.
§Capabilities
- Multi-Message Support: Parses all 24 supported MT message types
- Flexible Parsing: Both type-specific and auto-detection parsing modes
- Robust Error Handling: Comprehensive error reporting for malformed messages
- Field Validation: Format validation and business rule checking
- Position Tracking: Maintains field order for sequential processing requirements
§Parsing Process
- Block Extraction: Identifies and extracts SWIFT blocks 1-5
- Header Validation: Parses and validates basic, application, user headers and trailer
- Message Type Detection: Determines message type from application header
- Field Processing: Parses block 4 fields with position and variant tracking
- Type Construction: Builds strongly-typed message structures
- Validation: Applies format and business rule validation
§Thread Safety
SwiftParser is stateless and thread-safe. All methods are static and can be called concurrently from multiple threads.
Implementations§
Source§impl SwiftParser
impl SwiftParser
Sourcepub fn with_config(config: ParserConfig) -> Self
pub fn with_config(config: ParserConfig) -> Self
Create a new parser with custom configuration
Sourcepub fn parse_with_errors<T: SwiftMessageBody>(
&self,
raw_message: &str,
) -> Result<ParseResult<SwiftMessage<T>>>
pub fn parse_with_errors<T: SwiftMessageBody>( &self, raw_message: &str, ) -> Result<ParseResult<SwiftMessage<T>>>
Parse a message and return ParseResult with all errors collected
Sourcepub fn parse<T: SwiftMessageBody>(raw_message: &str) -> Result<SwiftMessage<T>>
pub fn parse<T: SwiftMessageBody>(raw_message: &str) -> Result<SwiftMessage<T>>
Parse a raw SWIFT message string into a typed message (static method for backward compatibility)
Sourcepub fn parse_message<T: SwiftMessageBody>(
&self,
raw_message: &str,
) -> Result<SwiftMessage<T>>
pub fn parse_message<T: SwiftMessageBody>( &self, raw_message: &str, ) -> Result<SwiftMessage<T>>
Parse a raw SWIFT message string into a typed message with configuration support
Sourcepub fn parse_auto(raw_message: &str) -> Result<ParsedSwiftMessage>
pub fn parse_auto(raw_message: &str) -> Result<ParsedSwiftMessage>
Parse a raw SWIFT message string with automatic message type detection (static method for backward compatibility)
Sourcepub fn parse_message_auto(
&self,
raw_message: &str,
) -> Result<ParsedSwiftMessage>
pub fn parse_message_auto( &self, raw_message: &str, ) -> Result<ParsedSwiftMessage>
Parse a raw SWIFT message string with automatic message type detection and configuration support
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SwiftParser
impl RefUnwindSafe for SwiftParser
impl Send for SwiftParser
impl Sync for SwiftParser
impl Unpin for SwiftParser
impl UnwindSafe for SwiftParser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more