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

use super::super::enums::ContAmtType;

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

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

impl<'a> ContAmtGrp<'a> {
    pub(in super::super) const TABLE: GroupTable<'static> = GroupTable::new(
        Tag(518),
        Tag(519),
        &[Tag(519), Tag(520), Tag(521)],
        &[],
    );

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

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

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

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

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

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