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

use super::super::components::{
    Header, InstrmtGrp, InstrmtLegGrp, LinesOfTextGrp, RoutingGrp, Trailer, UndInstrmtGrp,
};
use super::super::enums::EmailType;

/// The `Email` (35=C) message.
pub struct Email(RawMessage);

impl Email {
    pub const MSG_TYPE: &[u8] = b"C";

    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[
                Tag(164), Tag(94), Tag(42), Tag(147), Tag(356), Tag(357), Tag(215), Tag(146),
                Tag(711), Tag(555), Tag(37), Tag(11), Tag(33), Tag(95), Tag(96),
            ],
            &[
                Header::known_tags(), Trailer::known_tags(), RoutingGrp::known_tags(),
                InstrmtGrp::known_tags(), UndInstrmtGrp::known_tags(), InstrmtLegGrp::known_tags(),
                LinesOfTextGrp::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 `EmailThreadID` (164) field.
    #[doc(alias = "EmailThreadID")]
    pub fn email_thread_id(&self) -> Result<Option<&str>, InvalidValue> {
        self.0.get_str(Tag(164))
    }

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

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

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

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

    /// The `EncodedSubject` (357) field.
    #[doc(alias = "EncodedSubject")]
    pub fn encoded_subject(&self) -> Option<&[u8]> {
        self.0.get(Tag(357))
    }

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

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

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

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

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

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

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

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