Skip to main content

hotfix_message/parts/
repeating_group.rs

1use crate::HardCodedFixFieldDefinition;
2use crate::field_map::FieldMap;
3use crate::parts::Part;
4use hotfix_dictionary::{IsFieldDefinition, TagU32};
5
6/// Represents a FIX repeating group, such as a party in the list of parties.
7#[derive(Clone, Debug)]
8pub struct RepeatingGroup {
9    pub(crate) start_tag: TagU32,
10    pub(crate) delimiter_tag: TagU32,
11    fields: FieldMap,
12}
13
14impl RepeatingGroup {
15    /// Creates a new empty repeating group.
16    pub fn new(
17        start_tag: &HardCodedFixFieldDefinition,
18        delimiter_tag: &HardCodedFixFieldDefinition,
19    ) -> Self {
20        Self::new_with_tags(start_tag.tag(), delimiter_tag.tag())
21    }
22
23    pub(crate) fn new_with_tags(start_tag: TagU32, delimiter_tag: TagU32) -> Self {
24        Self {
25            start_tag,
26            delimiter_tag,
27            fields: FieldMap::default(),
28        }
29    }
30
31    pub fn get_fields(&self) -> &FieldMap {
32        &self.fields
33    }
34}
35
36impl Part for RepeatingGroup {
37    fn get_field_map(&self) -> &FieldMap {
38        &self.fields
39    }
40
41    fn get_field_map_mut(&mut self) -> &mut FieldMap {
42        &mut self.fields
43    }
44}