Struct Field20

Source
pub struct Field20 {
    pub transaction_reference: String,
}
Expand description

§Field 20: Transaction Reference

§Overview

Field 20 contains the sender’s reference to identify the related transaction uniquely. This field is mandatory in most SWIFT MT messages and serves as the primary identifier for transaction tracking, reconciliation, and reference purposes throughout the payment processing lifecycle.

§Format Specification

Format: 16x

  • 16x: Up to 16 alphanumeric characters
  • Character set: A-Z, a-z, 0-9, and limited special characters
  • Case sensitivity: Preserved as entered
  • Padding: No padding required (variable length up to 16 characters)

§Structure and Content

The transaction reference typically follows institutional naming conventions:

FT21234567890123
│└─────────────┘
│  Reference ID
└── Transaction type prefix (optional)

§Common Reference Patterns

Different institutions use various patterns for transaction references:

  • Sequential: FT000001, FT000002, FT000003
  • Date-based: FT20241201001, FT20241201002
  • Branch-based: NYC001234567, LON987654321
  • System-generated: TXN1234567890, REF0987654321
  • Customer-based: CUST12345678, CLI0000012345

§Usage Context

Field 20 is used in numerous SWIFT MT message types:

  • MT103: Single Customer Credit Transfer
  • MT202: General Financial Institution Transfer
  • MT202COV: Cover for customer credit transfer
  • MT900: Confirmation of Debit
  • MT910: Confirmation of Credit
  • MT950: Statement Message
  • MT940: Customer Statement Message

§Business Applications

  • Transaction tracking: Unique identification across systems
  • Reconciliation: Matching payments with confirmations
  • Audit trails: Regulatory compliance and investigation
  • Customer service: Reference for inquiries and disputes
  • STP processing: Automated transaction processing
  • Nostro reconciliation: Account statement matching

§Validation Rules

  1. Length: Maximum 16 characters
  2. Character set: Alphanumeric characters and limited special characters
  3. Uniqueness: Should be unique within sender’s system for the day
  4. Non-empty: Cannot be empty or contain only whitespace
  5. Format consistency: Should follow institutional standards

§Network Validated Rules (SWIFT Standards)

  • Transaction reference must not exceed 16 characters (Error: T13)
  • Must contain valid SWIFT character set (Error: T61)
  • Cannot be empty (Error: T18)
  • Should be unique per sender per day (Warning: recommended practice)

§Examples

:20:FT21234567890
└─── Wire transfer reference

:20:TXN0000012345
└─── System-generated transaction ID

:20:NYC20241201001
└─── Branch and date-based reference

:20:CUST123456789A
└─── Customer-based reference with check digit

Fields§

§transaction_reference: String

Transaction reference value (maximum 16 characters)

Contains the sender’s unique reference for the transaction. This value is used throughout the payment processing lifecycle for tracking, reconciliation, and audit purposes.

Format: Up to 16 alphanumeric characters Character set: A-Z, a-z, 0-9, and limited special characters Case sensitivity: Preserved as entered Uniqueness: Should be unique within sender’s system per day

§Examples

  • "FT21234567890" - Wire transfer reference
  • "TXN0000012345" - System-generated ID
  • "NYC20241201001" - Branch and date-based
  • "CUST123456789A" - Customer-based with check digit

Implementations§

Source§

impl Field20

Source

pub fn new(transaction_reference: String) -> Self

Create a new Field20 with comprehensive validation

Creates a new transaction reference field with the provided reference string. The reference is validated for length and character set compliance.

§Arguments
  • transaction_reference - The transaction reference string (max 16 chars)
§Examples
use swift_mt_message::fields::Field20;

// Standard wire transfer reference
let field = Field20::new("FT21234567890".to_string());

// System-generated transaction ID
let field = Field20::new("TXN0000012345".to_string());

// Date-based reference
let field = Field20::new("20241201001".to_string());
§Validation

The constructor performs basic validation but full validation occurs when calling validate() method or during SWIFT message processing.

Source

pub fn transaction_reference(&self) -> &str

Get the transaction reference value

Returns the transaction reference string that uniquely identifies this transaction within the sender’s system.

§Returns

A string slice containing the transaction reference

§Example
let field = Field20::new("FT21234567890".to_string());
assert_eq!(field.transaction_reference(), "FT21234567890");
Source

pub fn reference_pattern(&self) -> &'static str

Check if the reference follows a common pattern

Analyzes the transaction reference to determine if it follows common institutional patterns for reference generation.

§Returns

A string describing the detected pattern, or “Custom” if no pattern is detected

§Example
let ft_ref = Field20::new("FT21234567890".to_string());
assert_eq!(ft_ref.reference_pattern(), "Wire Transfer");

let txn_ref = Field20::new("TXN0000012345".to_string());
assert_eq!(txn_ref.reference_pattern(), "Transaction ID");
Source

pub fn is_date_based(&self) -> bool

Check if the reference appears to be date-based

Determines if the transaction reference contains date information based on common date patterns in reference strings.

§Returns

true if the reference appears to contain date information

§Example
let date_ref = Field20::new("20241201001".to_string());
assert!(date_ref.is_date_based());

let simple_ref = Field20::new("FT12345".to_string());
assert!(!simple_ref.is_date_based());
Source

pub fn sequence_number(&self) -> Option<u32>

Extract potential sequence number from reference

Attempts to extract a sequence number from the transaction reference, which is commonly found at the end of structured references.

§Returns

Some(number) if a sequence number is found, None otherwise

§Example
let seq_ref = Field20::new("FT001".to_string());
assert_eq!(seq_ref.sequence_number(), Some(1));

let no_seq = Field20::new("CUSTOMREF".to_string());
assert_eq!(no_seq.sequence_number(), None);
Source

pub fn description(&self) -> String

Get a human-readable description of the transaction reference

Returns a descriptive string explaining the transaction reference format and detected patterns.

§Returns

A descriptive string

§Example
let field = Field20::new("FT21234567890".to_string());
println!("{}", field.description());
Source

pub fn is_well_formed(&self) -> bool

Validate reference format according to institutional standards

Performs additional validation beyond the standard SWIFT field validation, checking for common institutional reference format requirements.

§Returns

true if the reference follows good practices, false otherwise

§Example
let good_ref = Field20::new("FT21234567890".to_string());
assert!(good_ref.is_well_formed());

let poor_ref = Field20::new("x".to_string());
assert!(!poor_ref.is_well_formed());

Trait Implementations§

Source§

impl Clone for Field20

Source§

fn clone(&self) -> Field20

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Field20

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Field20

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Field20

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Field20

Source§

fn eq(&self, other: &Field20) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Field20

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl SwiftField for Field20

Source§

fn parse(value: &str) -> Result<Self>

Parse field value from string representation
Source§

fn to_swift_string(&self) -> String

Convert field back to SWIFT string format
Source§

fn validate(&self) -> ValidationResult

Validate field according to SWIFT format rules
Source§

fn format_spec() -> &'static str

Get field format specification
Source§

impl StructuralPartialEq for Field20

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,