pub struct FieldConsumptionTracker { /* private fields */ }
Expand description
Field consumption tracker for sequential processing of duplicate fields
§Purpose
Ensures that when a message contains multiple instances of the same field (e.g., multiple :50: fields), they are consumed sequentially in the order they appear in the original message. This is critical for messages like MT101 where sequence matters.
§Implementation
- Tracks consumed field indices by tag
- Provides next available field value for sequential consumption
- Maintains message order integrity during field processing
§Example
use swift_mt_message::parser::FieldConsumptionTracker;
let mut tracker = FieldConsumptionTracker::new();
// Field "50" has values at positions [5, 15, 25] in message
let field_values = vec![
("value1".to_string(), 5),
("value2".to_string(), 15),
("value3".to_string(), 25),
];
let (value1, pos1) = tracker.get_next_available("50", &field_values).unwrap();
tracker.mark_consumed("50", pos1);
let (value2, pos2) = tracker.get_next_available("50", &field_values).unwrap();
// Ensures value2 is from position 15, not 5 or 25
Implementations§
Source§impl FieldConsumptionTracker
impl FieldConsumptionTracker
Sourcepub fn mark_consumed(&mut self, tag: &str, index: usize)
pub fn mark_consumed(&mut self, tag: &str, index: usize)
Mark a field value at a specific position as consumed
Trait Implementations§
Source§impl Clone for FieldConsumptionTracker
impl Clone for FieldConsumptionTracker
Source§fn clone(&self) -> FieldConsumptionTracker
fn clone(&self) -> FieldConsumptionTracker
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for FieldConsumptionTracker
impl Debug for FieldConsumptionTracker
Auto Trait Implementations§
impl Freeze for FieldConsumptionTracker
impl RefUnwindSafe for FieldConsumptionTracker
impl Send for FieldConsumptionTracker
impl Sync for FieldConsumptionTracker
impl Unpin for FieldConsumptionTracker
impl UnwindSafe for FieldConsumptionTracker
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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