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

use super::super::components::{Header, Trailer};
use super::super::enums::{EncryptMethod, MsgDirection};

/// The `Logon` (35=A) message.
pub struct Logon(RawMessage);

impl Logon {
    pub const MSG_TYPE: &[u8] = b"A";

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[
                Tag(98), Tag(108), Tag(95), Tag(96), Tag(141), Tag(789), Tag(383), Tag(384),
                Tag(464), Tag(553), Tag(554),
            ],
            &[Header::known_tags(), Trailer::known_tags(), LogonMsgTypes::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 `EncryptMethod` (98) field.
    #[doc(alias = "EncryptMethod")]
    pub fn encrypt_method(&self) -> Result<Option<EncryptMethod>, InvalidValue> {
        Ok(self.0.get_int(Tag(98))?.map(EncryptMethod::from_value))
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

impl<'a> LogonMsgTypes<'a> {
    pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
        Tag(384),
        Tag(372),
        &[Tag(372), Tag(385)],
        &[],
    );

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

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

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

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

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