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::YieldType;

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

impl<'a> YieldData<'a> {
    pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
        static TAGS: LazyKnownTags = LazyKnownTags::new(
            &[Tag(235), Tag(236), Tag(701), Tag(696), Tag(697), Tag(698)],
            &[],
        );
        &TAGS
    }

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

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

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

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

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

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

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

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