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::{InvalidValue, LazyKnownTags, RawMessage, Tag};

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

/// The `TradingSessionStatusRequest` (35=g) message.
pub struct TradingSessionStatusRequest(RawMessage);

impl TradingSessionStatusRequest {
    pub const MSG_TYPE: &[u8] = b"g";

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[Tag(335), Tag(336), Tag(625), Tag(338), Tag(339), Tag(263)],
            &[Header::known_tags(), Trailer::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 `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 `TradingSessionSubID` (625) field.
    #[doc(alias = "TradingSessionSubID")]
    pub fn trading_session_sub_id(&self) -> Result<Option<&str>, InvalidValue> {
        self.0.get_str(Tag(625))
    }

    /// 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 `SubscriptionRequestType` (263) field.
    #[doc(alias = "SubscriptionRequestType")]
    pub fn subscription_request_type(&self) -> Result<Option<SubscriptionRequestType<'_>>, InvalidValue> {
        Ok(self.0.get_str(Tag(263))?.map(SubscriptionRequestType::from_value))
    }
}

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

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