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

use super::super::enums::{DeliveryType, TerminationType};

/// The fields of the `FinancingDetails` component.
#[derive(Clone, Copy)]
pub struct FinancingDetails<'a>(pub(in super::super) refix_message::Scope<'a>);

impl<'a> FinancingDetails<'a> {
    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[
                Tag(913), Tag(914), Tag(915), Tag(918), Tag(788), Tag(916), Tag(917), Tag(919),
                Tag(898),
            ],
            &[],
        );
        &TAGS
    }

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

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

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

    /// The `AgreementDate` (915) field.
    #[doc(alias = "AgreementDate")]
    pub fn agreement_date(&self) -> Result<Option<Date>, InvalidValue> {
        self.0.get_date(Tag(915))
    }

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

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

    /// The `StartDate` (916) field.
    #[doc(alias = "StartDate")]
    pub fn start_date(&self) -> Result<Option<Date>, InvalidValue> {
        self.0.get_date(Tag(916))
    }

    /// The `EndDate` (917) field.
    #[doc(alias = "EndDate")]
    pub fn end_date(&self) -> Result<Option<Date>, InvalidValue> {
        self.0.get_date(Tag(917))
    }

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

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

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