#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{Date, Decimal, InvalidValue, LazyKnownTags, Tag};
use super::super::enums::YieldType;
#[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
}
#[doc(alias = "YieldType")]
pub fn yield_type(&self) -> Result<Option<YieldType<'a>>, InvalidValue> {
Ok(self.0.get_str(Tag(235))?.map(YieldType::from_value))
}
#[doc(alias = "Yield")]
pub fn r#yield(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(236))
}
#[doc(alias = "YieldCalcDate")]
pub fn yield_calc_date(&self) -> Result<Option<Date>, InvalidValue> {
self.0.get_date(Tag(701))
}
#[doc(alias = "YieldRedemptionDate")]
pub fn yield_redemption_date(&self) -> Result<Option<Date>, InvalidValue> {
self.0.get_date(Tag(696))
}
#[doc(alias = "YieldRedemptionPrice")]
pub fn yield_redemption_price(&self) -> Result<Option<Decimal>, InvalidValue> {
self.0.get_decimal(Tag(697))
}
#[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()))
}
}