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,
    UtcTimestamp,
};

use super::super::components::{Header, Trailer};
use super::super::enums::{IDSource, PutOrCall, RoutingType, SecurityType, Urgency};

/// The `News` (35=B) message.
pub struct News(RawMessage);

impl News {
    pub const MSG_TYPE: &[u8] = b"B";

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[
                Tag(42), Tag(61), Tag(148), Tag(358), Tag(359), Tag(215), Tag(146), Tag(33),
                Tag(149), Tag(95), Tag(96),
            ],
            &[
                Header::known_tags(), Trailer::known_tags(), NewsRoutingIDs::known_tags(),
                NewsRelatedSym::known_tags(), NewsLinesOfText::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 `OrigTime` (42) field.
    #[doc(alias = "OrigTime")]
    pub fn orig_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
        self.0.get_utc_timestamp(Tag(42))
    }

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

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

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

    /// The `EncodedHeadline` (359) field.
    #[doc(alias = "EncodedHeadline")]
    pub fn encoded_headline(&self) -> Option<&[u8]> {
        self.0.get(Tag(359))
    }

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

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

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

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

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

    /// The `RawData` (96) field.
    #[doc(alias = "RawData")]
    pub fn raw_data(&self) -> Option<&[u8]> {
        self.0.get(Tag(96))
    }
}

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

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

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

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

impl<'a> NewsRoutingIDs<'a> {
    pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
        Tag(215),
        Tag(216),
        &[Tag(216), Tag(217)],
        &[],
    );

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(&[Tag(216), Tag(217)], &[]);
        &TAGS
    }

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

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

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

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

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

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

impl<'a> NewsRelatedSym<'a> {
    pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
        Tag(146),
        Tag(46),
        &[
            Tag(22), Tag(46), Tag(48), Tag(65), Tag(106), Tag(107), Tag(167), Tag(200), Tag(201),
            Tag(202), Tag(205), Tag(206), Tag(207), Tag(223), Tag(231), Tag(348), Tag(349),
            Tag(350), Tag(351),
        ],
        &[],
    );

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[
                Tag(46), 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),
            ],
            &[],
        );
        &TAGS
    }

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

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

    /// 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 `IDSource` (22) field.
    #[doc(alias = "IDSource")]
    pub fn id_source(&self) -> Result<Option<IDSource<'a>>, 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<'a>>, 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<&'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))
    }
}

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

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

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

impl<'a> NewsLinesOfText<'a> {
    pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
        Tag(33),
        Tag(58),
        &[Tag(58), Tag(354), Tag(355)],
        &[],
    );

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(&[Tag(58), Tag(354), Tag(355)], &[]);
        &TAGS
    }

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

    /// 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 NewsLinesOfText<'_> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "NewsLinesOfText({})", self.0)
    }
}