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, Instances, InvalidValue, LazyKnownTags, MultipleValues, RawMessage, Tag, UtcTimestamp,
};

use super::super::components::{
    Header, InstrmtLegGrp, Instrument, InstrumentExtension, Trailer, UndInstrmtGrp,
};
use super::super::enums::{
    Adjustment, CorporateAction, FinancialStatus, HaltReasonChar, SecurityTradingStatus,
};

/// The `SecurityStatus` (35=f) message.
pub struct SecurityStatus(RawMessage);

impl SecurityStatus {
    pub const MSG_TYPE: &[u8] = b"f";

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[
                Tag(324), Tag(711), Tag(555), Tag(15), Tag(336), Tag(625), Tag(325), Tag(326),
                Tag(291), Tag(292), Tag(327), Tag(328), Tag(329), Tag(330), Tag(331), Tag(332),
                Tag(333), Tag(31), Tag(60), Tag(334), Tag(58), Tag(354), Tag(355),
            ],
            &[
                Header::known_tags(), Trailer::known_tags(), Instrument::known_tags(),
                InstrumentExtension::known_tags(), UndInstrmtGrp::known_tags(),
                InstrmtLegGrp::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(), Self::known_tags().get())
    }

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

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

    /// The `Instrument` component.
    pub fn instrument(&self) -> Instrument<'_> {
        Instrument(self.0.scope(), Self::known_tags().get())
    }

    /// The `InstrumentExtension` component.
    pub fn instrument_extension(&self) -> InstrumentExtension<'_> {
        InstrumentExtension(self.0.scope(), Self::known_tags().get())
    }

    /// The instances of the `NoUnderlyings` (711) group.
    #[doc(alias = "NoUnderlyings")]
    pub fn underlyings(&self) -> Result<Instances<'_, UndInstrmtGrp<'_>>, 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<'_, InstrmtLegGrp<'_>>, InvalidValue> {
        self.0.get_group(&InstrmtLegGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
    }

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

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

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

    /// The `UnsolicitedIndicator` (325) field.
    #[doc(alias = "UnsolicitedIndicator")]
    pub fn unsolicited_indicator(&self) -> Result<Option<bool>, InvalidValue> {
        self.0.get_bool(Tag(325))
    }

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

    /// The `FinancialStatus` (291) field.
    #[doc(alias = "FinancialStatus")]
    pub fn financial_status(&self) -> Result<Option<MultipleValues<'_, FinancialStatus<'_>>>, InvalidValue> {
        self.0.get_multiple_values(Tag(291))
    }

    /// The `CorporateAction` (292) field.
    #[doc(alias = "CorporateAction")]
    pub fn corporate_action(&self) -> Result<Option<MultipleValues<'_, CorporateAction<'_>>>, InvalidValue> {
        self.0.get_multiple_values(Tag(292))
    }

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

    /// The `InViewOfCommon` (328) field.
    #[doc(alias = "InViewOfCommon")]
    pub fn in_view_of_common(&self) -> Result<Option<bool>, InvalidValue> {
        self.0.get_bool(Tag(328))
    }

    /// The `DueToRelated` (329) field.
    #[doc(alias = "DueToRelated")]
    pub fn due_to_related(&self) -> Result<Option<bool>, InvalidValue> {
        self.0.get_bool(Tag(329))
    }

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

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

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

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

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

    /// The `TransactTime` (60) field.
    #[doc(alias = "TransactTime")]
    pub fn transact_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
        self.0.get_utc_timestamp(Tag(60))
    }

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

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

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

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