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

use super::super::enums::{CPProgram, Product, PutOrCall, SecurityIDSource, SecurityType};
use super::{EvntGrp, SecAltIDGrp};

/// The fields of the `Instrument` component.
#[derive(Clone, Copy)]
pub struct Instrument<'a>(
    pub(in super::super) refix_message::Scope<'a>,
    pub(in super::super) KnownTags<'static>,
);

impl<'a> Instrument<'a> {
    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[
                Tag(55), Tag(65), Tag(48), Tag(22), Tag(454), Tag(460), Tag(461), Tag(167),
                Tag(762), Tag(200), Tag(541), Tag(201), Tag(224), Tag(225), Tag(239), Tag(226),
                Tag(227), Tag(228), Tag(255), Tag(543), Tag(470), Tag(471), Tag(472), Tag(240),
                Tag(202), Tag(947), Tag(206), Tag(231), Tag(223), Tag(207), Tag(106), Tag(348),
                Tag(349), Tag(107), Tag(350), Tag(351), Tag(691), Tag(667), Tag(875), Tag(876),
                Tag(864), Tag(873), Tag(874),
            ],
            &[SecAltIDGrp::known_tags(), EvntGrp::known_tags()],
        );
        &TAGS
    }

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

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

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

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

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

    /// The instances of the `NoSecurityAltID` (454) group.
    #[doc(alias = "NoSecurityAltID")]
    pub fn security_alt_id(&self) -> Result<Instances<'a, SecAltIDGrp<'a>>, InvalidValue> {
        self.0.get_group(&SecAltIDGrp::TABLE, &self.1).map(Instances::from)
    }

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

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

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

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

    /// The `MaturityMonthYear` (200) field.
    #[doc(alias = "MaturityMonthYear")]
    pub fn maturity_month_year(&self) -> Result<Option<MonthYear>, InvalidValue> {
        self.0.get_month_year(Tag(200))
    }

    /// The `MaturityDate` (541) field.
    #[doc(alias = "MaturityDate")]
    pub fn maturity_date(&self) -> Result<Option<Date>, InvalidValue> {
        self.0.get_date(Tag(541))
    }

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

    /// The `CouponPaymentDate` (224) field.
    #[doc(alias = "CouponPaymentDate")]
    pub fn coupon_payment_date(&self) -> Result<Option<Date>, InvalidValue> {
        self.0.get_date(Tag(224))
    }

    /// The `IssueDate` (225) field.
    #[doc(alias = "IssueDate")]
    pub fn issue_date(&self) -> Result<Option<Date>, InvalidValue> {
        self.0.get_date(Tag(225))
    }

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

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

    /// The `RepurchaseRate` (227) field.
    #[doc(alias = "RepurchaseRate")]
    pub fn repurchase_rate(&self) -> Result<Option<Decimal>, InvalidValue> {
        self.0.get_decimal(Tag(227))
    }

    /// The `Factor` (228) field.
    #[doc(alias = "Factor")]
    pub fn factor(&self) -> Result<Option<Decimal>, InvalidValue> {
        self.0.get_decimal(Tag(228))
    }

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

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

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

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

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

    /// The `RedemptionDate` (240) field.
    #[doc(alias = "RedemptionDate")]
    pub fn redemption_date(&self) -> Result<Option<Date>, InvalidValue> {
        self.0.get_date(Tag(240))
    }

    /// The `StrikePrice` (202) field.
    #[doc(alias = "StrikePrice")]
    pub fn strike_price(&self) -> Result<Option<Decimal>, InvalidValue> {
        self.0.get_decimal(Tag(202))
    }

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

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

    /// The `ContractMultiplier` (231) field.
    #[doc(alias = "ContractMultiplier")]
    pub fn contract_multiplier(&self) -> Result<Option<Decimal>, InvalidValue> {
        self.0.get_decimal(Tag(231))
    }

    /// The `CouponRate` (223) field.
    #[doc(alias = "CouponRate")]
    pub fn coupon_rate(&self) -> Result<Option<Decimal>, InvalidValue> {
        self.0.get_decimal(Tag(223))
    }

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

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

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

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

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

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

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

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

    /// The `ContractSettlMonth` (667) field.
    #[doc(alias = "ContractSettlMonth")]
    pub fn contract_settl_month(&self) -> Result<Option<MonthYear>, InvalidValue> {
        self.0.get_month_year(Tag(667))
    }

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

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

    /// The instances of the `NoEvents` (864) group.
    #[doc(alias = "NoEvents")]
    pub fn events(&self) -> Result<Instances<'a, EvntGrp<'a>>, InvalidValue> {
        self.0.get_group(&EvntGrp::TABLE, &self.1).map(Instances::from)
    }

    /// The `DatedDate` (873) field.
    #[doc(alias = "DatedDate")]
    pub fn dated_date(&self) -> Result<Option<Date>, InvalidValue> {
        self.0.get_date(Tag(873))
    }

    /// The `InterestAccrualDate` (874) field.
    #[doc(alias = "InterestAccrualDate")]
    pub fn interest_accrual_date(&self) -> Result<Option<Date>, InvalidValue> {
        self.0.get_date(Tag(874))
    }
}

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