refix-fix44 0.12.0

Typed FIX 4.4 protocol messages for the ReFIX engine
Documentation
// @generated by refix codegen from FIX44.xml. Do not edit.
#![cfg_attr(rustfmt, rustfmt::skip)]

use refix_message::{GroupTable, Instances, InvalidValue, LazyKnownTags, Tag};

use super::super::enums::ExpirationCycle;
use super::{AttrbGrp, EvntGrp, InstrmtLegGrp, Instrument, InstrumentExtension, SecAltIDGrp};

/// An instance of the `NoRelatedSym` (146) group.
#[derive(Clone, Copy)]
pub struct RelSymDerivSecGrp<'a>(refix_message::Scope<'a>);

impl<'a> From<refix_message::Scope<'a>> for RelSymDerivSecGrp<'a> {
    fn from(scope: refix_message::Scope<'a>) -> Self {
        Self(scope)
    }
}

impl<'a> RelSymDerivSecGrp<'a> {
    pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
        Tag(146),
        Tag(55),
        &[
            Tag(15), Tag(22), Tag(48), Tag(55), Tag(58), Tag(65), Tag(106), Tag(107), Tag(167),
            Tag(200), Tag(201), Tag(202), Tag(206), Tag(207), Tag(223), Tag(224), Tag(225),
            Tag(226), Tag(227), Tag(228), Tag(231), Tag(239), Tag(240), Tag(255), Tag(336),
            Tag(348), Tag(349), Tag(350), Tag(351), Tag(354), Tag(355), Tag(454), Tag(460),
            Tag(461), Tag(470), Tag(471), Tag(472), Tag(541), Tag(543), Tag(555), Tag(625),
            Tag(667), Tag(668), Tag(691), Tag(762), Tag(827), Tag(864), Tag(869), Tag(870),
            Tag(873), Tag(874), Tag(875), Tag(876), Tag(947),
        ],
        &[SecAltIDGrp::TABLE, EvntGrp::TABLE, AttrbGrp::TABLE, InstrmtLegGrp::TABLE],
    );

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[Tag(15), Tag(827), Tag(555), Tag(336), Tag(625), Tag(58), Tag(354), Tag(355)],
            &[
                Instrument::known_tags(), InstrumentExtension::known_tags(),
                InstrmtLegGrp::known_tags(),
            ],
        );
        &TAGS
    }

    pub fn raw(&self) -> refix_message::Scope<'a> {
        self.0
    }

    /// The `Instrument` component.
    pub fn instrument(&self) -> Instrument<'a> {
        Instrument(self.0, Self::known_tags().get())
    }

    /// The `Currency` (15) field.
    #[doc(alias = "Currency")]
    pub fn currency(&self) -> Result<Option<&'a str>, InvalidValue> {
        self.0.get_str(Tag(15))
    }

    /// The `ExpirationCycle` (827) field.
    #[doc(alias = "ExpirationCycle")]
    pub fn expiration_cycle(&self) -> Result<Option<ExpirationCycle>, InvalidValue> {
        Ok(self.0.get_int(Tag(827))?.map(ExpirationCycle::from_value))
    }

    /// The `InstrumentExtension` component.
    pub fn instrument_extension(&self) -> InstrumentExtension<'a> {
        InstrumentExtension(self.0, Self::known_tags().get())
    }

    /// The instances of the `NoLegs` (555) group.
    #[doc(alias = "NoLegs")]
    pub fn legs(&self) -> Result<Instances<'a, InstrmtLegGrp<'a>>, InvalidValue> {
        self.0.get_group(&InstrmtLegGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
    }

    /// The `TradingSessionID` (336) field.
    #[doc(alias = "TradingSessionID")]
    pub fn trading_session_id(&self) -> Result<Option<&'a str>, InvalidValue> {
        self.0.get_str(Tag(336))
    }

    /// The `TradingSessionSubID` (625) field.
    #[doc(alias = "TradingSessionSubID")]
    pub fn trading_session_sub_id(&self) -> Result<Option<&'a str>, InvalidValue> {
        self.0.get_str(Tag(625))
    }

    /// The `Text` (58) field.
    #[doc(alias = "Text")]
    pub fn text(&self) -> Result<Option<&'a str>, InvalidValue> {
        self.0.get_str(Tag(58))
    }

    /// The `EncodedTextLen` (354) field.
    #[doc(alias = "EncodedTextLen")]
    pub fn encoded_text_len(&self) -> Result<Option<i64>, InvalidValue> {
        self.0.get_int(Tag(354))
    }

    /// The `EncodedText` (355) field.
    #[doc(alias = "EncodedText")]
    pub fn encoded_text(&self) -> Option<&'a [u8]> {
        self.0.get(Tag(355))
    }
}

impl std::fmt::Debug for RelSymDerivSecGrp<'_> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "RelSymDerivSecGrp({})", self.0)
    }
}