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, InvalidValue, MonthYear, RawMessage, Tag, UtcTimestamp};

use super::super::components::{Header, Trailer};
use super::super::enums::{
    Adjustment, CorporateAction, FinancialStatus, HaltReasonChar, IDSource, PutOrCall,
    SecurityTradingStatus, SecurityType,
};

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

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

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

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

    /// 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<FinancialStatus<'_>>, InvalidValue> {
        Ok(self.0.get_str(Tag(291))?.map(FinancialStatus::from_value))
    }

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

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

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