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::{PartyIDSource, PartyRole};
use super::PtysSubGrp;

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

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

impl<'a> Parties<'a> {
    pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
        Tag(453),
        Tag(448),
        &[Tag(447), Tag(448), Tag(452), Tag(802)],
        &[PtysSubGrp::TABLE],
    );

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[Tag(448), Tag(447), Tag(452), Tag(802)],
            &[PtysSubGrp::known_tags()],
        );
        &TAGS
    }

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

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

    /// The `PartyIDSource` (447) field.
    #[doc(alias = "PartyIDSource")]
    pub fn party_id_source(&self) -> Result<Option<PartyIDSource<'a>>, InvalidValue> {
        Ok(self.0.get_str(Tag(447))?.map(PartyIDSource::from_value))
    }

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

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

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