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::{Decimal, GroupTable, Instances, InvalidValue, LazyKnownTags, Tag};

use super::super::enums::{QuoteRequestType, QuoteType};
use super::{EvntGrp, InstrmtLegGrp, Instrument, SecAltIDGrp, UndInstrmtGrp};

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

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

impl<'a> RFQReqGrp<'a> {
    pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
        Tag(146),
        Tag(55),
        &[
            Tag(22), Tag(48), Tag(55), Tag(65), Tag(106), Tag(107), Tag(140), 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(303), Tag(336),
            Tag(348), Tag(349), Tag(350), Tag(351), Tag(454), Tag(460), Tag(461), Tag(470),
            Tag(471), Tag(472), Tag(537), Tag(541), Tag(543), Tag(555), Tag(625), Tag(667),
            Tag(691), Tag(711), Tag(762), Tag(864), Tag(873), Tag(874), Tag(875), Tag(876),
            Tag(947),
        ],
        &[SecAltIDGrp::TABLE, EvntGrp::TABLE, UndInstrmtGrp::TABLE, InstrmtLegGrp::TABLE],
    );

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[Tag(711), Tag(555), Tag(140), Tag(303), Tag(537), Tag(336), Tag(625)],
            &[Instrument::known_tags(), UndInstrmtGrp::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 instances of the `NoUnderlyings` (711) group.
    #[doc(alias = "NoUnderlyings")]
    pub fn underlyings(&self) -> Result<Instances<'a, UndInstrmtGrp<'a>>, InvalidValue> {
        self.0.get_group(&UndInstrmtGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
    }

    /// 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 `PrevClosePx` (140) field.
    #[doc(alias = "PrevClosePx")]
    pub fn prev_close_px(&self) -> Result<Option<Decimal>, InvalidValue> {
        self.0.get_decimal(Tag(140))
    }

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

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

    /// 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))
    }
}

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