refix-fix42 0.4.0

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

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

use super::super::components::{Header, Trailer};
use super::super::enums::{IDSource, PutOrCall, SecurityRequestType, SecurityType, Side};

/// The `SecurityDefinitionRequest` (35=c) message.
pub struct SecurityDefinitionRequest(RawMessage);

impl SecurityDefinitionRequest {
    pub const MSG_TYPE: &[u8] = b"c";

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[
                Tag(320), Tag(321), Tag(55), Tag(65), Tag(48), Tag(22), Tag(167), Tag(200),
                Tag(205), Tag(201), Tag(202), Tag(206), Tag(231), Tag(223), Tag(207), Tag(106),
                Tag(348), Tag(349), Tag(107), Tag(350), Tag(351), Tag(15), Tag(58), Tag(354),
                Tag(355), Tag(336), Tag(146),
            ],
            &[
                Header::known_tags(), Trailer::known_tags(),
                SecurityDefinitionRequestRelatedSym::known_tags(),
            ],
        );
        &TAGS
    }

    pub fn from_raw(raw: RawMessage) -> Self {
        Self(raw)
    }

    pub fn raw(&self) -> &RawMessage {
        &self.0
    }

    pub fn header(&self) -> Header<'_> {
        Header(self.0.scope())
    }

    pub fn trailer(&self) -> Trailer<'_> {
        Trailer(self.0.scope())
    }

    /// The `SecurityReqID` (320) field.
    #[doc(alias = "SecurityReqID")]
    pub fn security_req_id(&self) -> Result<Option<&str>, InvalidValue> {
        self.0.get_str(Tag(320))
    }

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

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

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

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

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

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

    /// 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 `MaturityDay` (205) field.
    #[doc(alias = "MaturityDay")]
    pub fn maturity_day(&self) -> Result<Option<i64>, InvalidValue> {
        self.0.get_int(Tag(205))
    }

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

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

    /// The `Issuer` (106) field.
    #[doc(alias = "Issuer")]
    pub fn issuer(&self) -> Result<Option<&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<&[u8]> {
        self.0.get(Tag(349))
    }

    /// The `SecurityDesc` (107) field.
    #[doc(alias = "SecurityDesc")]
    pub fn security_desc(&self) -> Result<Option<&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<&[u8]> {
        self.0.get(Tag(351))
    }

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

    /// The `Text` (58) field.
    #[doc(alias = "Text")]
    pub fn text(&self) -> Result<Option<&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<&[u8]> {
        self.0.get(Tag(355))
    }

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

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

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

impl std::fmt::Display for SecurityDefinitionRequest {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        std::fmt::Display::fmt(&self.0, f)
    }
}

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

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

impl<'a> SecurityDefinitionRequestRelatedSym<'a> {
    pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
        Tag(146),
        Tag(311),
        &[
            Tag(54), Tag(305), Tag(306), Tag(307), Tag(308), Tag(309), Tag(310), Tag(311), Tag(312),
            Tag(313), Tag(314), Tag(315), Tag(316), Tag(317), Tag(318), Tag(319), Tag(362),
            Tag(363), Tag(364), Tag(365), Tag(435), Tag(436),
        ],
        &[],
    );

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[
                Tag(311), Tag(312), Tag(309), Tag(305), Tag(310), Tag(313), Tag(314), Tag(315),
                Tag(316), Tag(317), Tag(436), Tag(435), Tag(308), Tag(306), Tag(362), Tag(363),
                Tag(307), Tag(364), Tag(365), Tag(319), Tag(54), Tag(318),
            ],
            &[],
        );
        &TAGS
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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