Skip to main content

refix_fix44/generated/components/
position_qty.rs

1// @generated by refix codegen from FIX44.xml. Do not edit.
2#![cfg_attr(rustfmt, rustfmt::skip)]
3
4use refix_message::{Decimal, GroupTable, Instances, InvalidValue, LazyKnownTags, Tag};
5
6use super::super::enums::{PosQtyStatus, PosType};
7use super::NestedParties;
8
9/// An instance of the `NoPositions` (702) group.
10#[derive(Clone, Copy)]
11pub struct PositionQty<'a>(refix_message::Scope<'a>);
12
13impl<'a> From<refix_message::Scope<'a>> for PositionQty<'a> {
14    fn from(scope: refix_message::Scope<'a>) -> Self {
15        Self(scope)
16    }
17}
18
19impl<'a> PositionQty<'a> {
20    pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
21        Tag(702),
22        Tag(703),
23        &[Tag(539), Tag(703), Tag(704), Tag(705), Tag(706)],
24        &[NestedParties::TABLE],
25    );
26
27    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
28        static TAGS: LazyKnownTags = LazyKnownTags::new(
29            &[Tag(703), Tag(704), Tag(705), Tag(706), Tag(539)],
30            &[NestedParties::known_tags()],
31        );
32        &TAGS
33    }
34
35    pub fn raw(&self) -> refix_message::Scope<'a> {
36        self.0
37    }
38
39    /// The `PosType` (703) field.
40    #[doc(alias = "PosType")]
41    pub fn pos_type(&self) -> Result<Option<PosType<'a>>, InvalidValue> {
42        Ok(self.0.get_str(Tag(703))?.map(PosType::from_value))
43    }
44
45    /// The `LongQty` (704) field.
46    #[doc(alias = "LongQty")]
47    pub fn long_qty(&self) -> Result<Option<Decimal>, InvalidValue> {
48        self.0.get_decimal(Tag(704))
49    }
50
51    /// The `ShortQty` (705) field.
52    #[doc(alias = "ShortQty")]
53    pub fn short_qty(&self) -> Result<Option<Decimal>, InvalidValue> {
54        self.0.get_decimal(Tag(705))
55    }
56
57    /// The `PosQtyStatus` (706) field.
58    #[doc(alias = "PosQtyStatus")]
59    pub fn pos_qty_status(&self) -> Result<Option<PosQtyStatus>, InvalidValue> {
60        Ok(self.0.get_int(Tag(706))?.map(PosQtyStatus::from_value))
61    }
62
63    /// The instances of the `NoNestedPartyIDs` (539) group.
64    #[doc(alias = "NoNestedPartyIDs")]
65    pub fn nested_party_ids(&self) -> Result<Instances<'a, NestedParties<'a>>, InvalidValue> {
66        self.0.get_group(&NestedParties::TABLE, &Self::known_tags().get()).map(Instances::from)
67    }
68}
69
70impl std::fmt::Debug for PositionQty<'_> {
71    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
72        write!(f, "PositionQty({})", self.0)
73    }
74}