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

use super::super::components::{Header, Trailer};
use super::super::enums::{TradSesMethod, TradSesMode, TradSesStatus};

/// The `TradingSessionStatus` (35=h) message.
pub struct TradingSessionStatus(RawMessage);

impl TradingSessionStatus {
    pub const MSG_TYPE: &[u8] = b"h";

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

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

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

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

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

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

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

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

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

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

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

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

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

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